Skip to content

Commit

Permalink
[Kafka.DotNet.ksqlDB] - scalar collection functions: ArrayMax, ArrayMin
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasfabian committed Apr 9, 2021
1 parent dff14be commit fa2eba4
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Joker.Kafka/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ Fixes:
- QbservableProvider
- ```KSqldbProvider<T>``` - ksqldb REST api provider for push queries (```KSqlDbQueryProvider<T>```, ```KSqlDbQueryStreamProvider<T>```)

# v0.8.0-preview (WIP) - not released yet
- scalar collection functions: ArrayMax, ArrayMin

# TODO:
- missing scalar functions https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-reference/scalar-functions/#date-and-time
- CreateQueryStream options parameter
Expand Down
128 changes: 123 additions & 5 deletions Joker.Kafka/KSql/Query/Functions/KSqlFunctionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ public static string ArrayJoin(this KSqlFunctions kSqlFunctions, decimal[] array
/// </summary>
/// <param name="kSqlFunctions"></param>
/// <param name="array">The array</param>
/// <returns>Returns the maximum value from within a given array of primitive elements (not arrays of other arrays, or maps, or structs, or combinations thereof).</returns>
/// <returns>Number of elements in the array. If the array field is NULL, or contains only NULLs, then NULL is returned.</returns>
public static int? ArrayLength(this KSqlFunctions kSqlFunctions, string[] array)
{
throw new InvalidOperationException(ServerSideOperationErrorMessage);
Expand All @@ -1014,7 +1014,7 @@ public static string ArrayJoin(this KSqlFunctions kSqlFunctions, decimal[] array
/// </summary>
/// <param name="kSqlFunctions"></param>
/// <param name="array">The array</param>
/// <returns>Returns the maximum value from within a given array of primitive elements (not arrays of other arrays, or maps, or structs, or combinations thereof).</returns>
/// <returns>Number of elements in the array. If the array field is NULL, or contains only NULLs, then NULL is returned.</returns>
public static int? ArrayLength(this KSqlFunctions kSqlFunctions, int[] array)
{
throw new InvalidOperationException(ServerSideOperationErrorMessage);
Expand All @@ -1025,7 +1025,7 @@ public static string ArrayJoin(this KSqlFunctions kSqlFunctions, decimal[] array
/// </summary>
/// <param name="kSqlFunctions"></param>
/// <param name="array">The array</param>
/// <returns>Returns the maximum value from within a given array of primitive elements (not arrays of other arrays, or maps, or structs, or combinations thereof).</returns>
/// <returns>Number of elements in the array. If the array field is NULL, or contains only NULLs, then NULL is returned.</returns>
public static int? ArrayLength(this KSqlFunctions kSqlFunctions, long[] array)
{
throw new InvalidOperationException(ServerSideOperationErrorMessage);
Expand All @@ -1036,7 +1036,7 @@ public static string ArrayJoin(this KSqlFunctions kSqlFunctions, decimal[] array
/// </summary>
/// <param name="kSqlFunctions"></param>
/// <param name="array">The array</param>
/// <returns>Returns the maximum value from within a given array of primitive elements (not arrays of other arrays, or maps, or structs, or combinations thereof).</returns>
/// <returns>Number of elements in the array. If the array field is NULL, or contains only NULLs, then NULL is returned.</returns>
public static int? ArrayLength(this KSqlFunctions kSqlFunctions, double[] array)
{
throw new InvalidOperationException(ServerSideOperationErrorMessage);
Expand All @@ -1047,7 +1047,7 @@ public static string ArrayJoin(this KSqlFunctions kSqlFunctions, decimal[] array
/// </summary>
/// <param name="kSqlFunctions"></param>
/// <param name="array">The array</param>
/// <returns>Returns the maximum value from within a given array of primitive elements (not arrays of other arrays, or maps, or structs, or combinations thereof).</returns>
/// <returns>Number of elements in the array. If the array field is NULL, or contains only NULLs, then NULL is returned.</returns>
public static int? ArrayLength(this KSqlFunctions kSqlFunctions, decimal[] array)
{
throw new InvalidOperationException(ServerSideOperationErrorMessage);
Expand All @@ -1057,6 +1057,124 @@ public static string ArrayJoin(this KSqlFunctions kSqlFunctions, decimal[] array

#region ARRAY_MAX

/// <summary>
/// Given an array, return the maximum value. Array entries are compared according to their natural sort order, which sorts the various data-types.
/// </summary>
/// <param name="kSqlFunctions"></param>
/// <param name="array">The array</param>
/// <returns>Returns the maximum value from within a given array of primitive elements (not arrays of other arrays, or maps, or structs, or combinations thereof).</returns>
public static int? ArrayMax(this KSqlFunctions kSqlFunctions, string[] array)
{
throw new InvalidOperationException(ServerSideOperationErrorMessage);
}

/// <summary>
/// Given an array, return the maximum value. Array entries are compared according to their natural sort order, which sorts the various data-types.
/// </summary>
/// <param name="kSqlFunctions"></param>
/// <param name="array">The array</param>
/// <returns>Returns the maximum value from within a given array of primitive elements (not arrays of other arrays, or maps, or structs, or combinations thereof).</returns>
public static int? ArrayMax(this KSqlFunctions kSqlFunctions, int[] array)
{
throw new InvalidOperationException(ServerSideOperationErrorMessage);
}

/// <summary>
/// Given an array, return the maximum value. Array entries are compared according to their natural sort order, which sorts the various data-types.
/// </summary>
/// <param name="kSqlFunctions"></param>
/// <param name="array">The array</param>
/// <returns>Returns the maximum value from within a given array of primitive elements (not arrays of other arrays, or maps, or structs, or combinations thereof).</returns>
public static int? ArrayMax(this KSqlFunctions kSqlFunctions, long[] array)
{
throw new InvalidOperationException(ServerSideOperationErrorMessage);
}

/// <summary>
/// Given an array, return the maximum value. Array entries are compared according to their natural sort order, which sorts the various data-types.
/// </summary>
/// <param name="kSqlFunctions"></param>
/// <param name="array">The array</param>
/// <returns>Returns the maximum value from within a given array of primitive elements (not arrays of other arrays, or maps, or structs, or combinations thereof).</returns>
public static int? ArrayMax(this KSqlFunctions kSqlFunctions, double[] array)
{
throw new InvalidOperationException(ServerSideOperationErrorMessage);
}

/// <summary>
/// Given an array, return the maximum value. Array entries are compared according to their natural sort order, which sorts the various data-types.
/// </summary>
/// <param name="kSqlFunctions"></param>
/// <param name="array">The array</param>
/// <returns>Returns the maximum value from within a given array of primitive elements (not arrays of other arrays, or maps, or structs, or combinations thereof).</returns>
public static int? ArrayMax(this KSqlFunctions kSqlFunctions, decimal[] array)
{
throw new InvalidOperationException(ServerSideOperationErrorMessage);
}

#endregion

#region ArrayMin

/// <summary>
/// Given an array, return the minimum value. Array entries are compared according to their natural sort order, which sorts the various data-types.
/// </summary>
/// <param name="kSqlFunctions"></param>
/// <param name="array">The array</param>
/// <returns>Returns the minimum value from within a given array of primitive elements (not arrays of other arrays, or maps, or structs, or combinations thereof).</returns>
public static int? ArrayMin(this KSqlFunctions kSqlFunctions, string[] array)
{
throw new InvalidOperationException(ServerSideOperationErrorMessage);
}

/// <summary>
/// Given an array, return the minimum value. Array entries are compared according to their natural sort order, which sorts the various data-types.
/// </summary>
/// <param name="kSqlFunctions"></param>
/// <param name="array">The array</param>
/// <returns>Returns the minimum value from within a given array of primitive elements (not arrays of other arrays, or maps, or structs, or combinations thereof).</returns>
public static int? ArrayMin(this KSqlFunctions kSqlFunctions, int[] array)
{
throw new InvalidOperationException(ServerSideOperationErrorMessage);
}

/// <summary>
/// Given an array, return the minimum value. Array entries are compared according to their natural sort order, which sorts the various data-types.
/// </summary>
/// <param name="kSqlFunctions"></param>
/// <param name="array">The array</param>
/// <returns>Returns the minimum value from within a given array of primitive elements (not arrays of other arrays, or maps, or structs, or combinations thereof).</returns>
public static int? ArrayMin(this KSqlFunctions kSqlFunctions, long[] array)
{
throw new InvalidOperationException(ServerSideOperationErrorMessage);
}

/// <summary>
/// Given an array, return the minimum value. Array entries are compared according to their natural sort order, which sorts the various data-types.
/// </summary>
/// <param name="kSqlFunctions"></param>
/// <param name="array">The array</param>
/// <returns>Returns the minimum value from within a given array of primitive elements (not arrays of other arrays, or maps, or structs, or combinations thereof).</returns>
public static int? ArrayMin(this KSqlFunctions kSqlFunctions, double[] array)
{
throw new InvalidOperationException(ServerSideOperationErrorMessage);
}

/// <summary>
/// Given an array, return the minimum value. Array entries are compared according to their natural sort order, which sorts the various data-types.
/// </summary>
/// <param name="kSqlFunctions"></param>
/// <param name="array">The array</param>
/// <returns>Returns the minimum value from within a given array of primitive elements (not arrays of other arrays, or maps, or structs, or combinations thereof).</returns>
public static int? ArrayMin(this KSqlFunctions kSqlFunctions, decimal[] array)
{
throw new InvalidOperationException(ServerSideOperationErrorMessage);
}

#endregion

#region ARRAY_REMOVE



#endregion
Expand Down
2 changes: 2 additions & 0 deletions Joker.Kafka/KSql/Query/Visitors/KSqlFunctionVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
case nameof(KSqlFunctionsExtensions.ArrayIntersect):
case nameof(KSqlFunctionsExtensions.ArrayJoin):
case nameof(KSqlFunctionsExtensions.ArrayLength):
case nameof(KSqlFunctionsExtensions.ArrayMax):
case nameof(KSqlFunctionsExtensions.ArrayMin):
Append($"{methodInfo.Name.ToKSqlFunctionName()}");
PrintFunctionArguments(methodCallExpression.Arguments.Skip(1));
break;
Expand Down

0 comments on commit fa2eba4

Please sign in to comment.