liuyongvs commented on code in PR #3260:
URL: https://github.com/apache/calcite/pull/3260#discussion_r1225698463
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -945,6 +964,27 @@ private static RelDataType
arrayReturnType(SqlOperatorBinding opBinding) {
ReturnTypes.TO_COLLECTION_ELEMENT_FORCE_NULLABLE,
OperandTypes.ARRAY);
+ /** The "ARRAY_POSITION(array, element)" function. */
+ @LibraryOperator(libraries = {SPARK})
+ public static final SqlFunction ARRAY_POSITION =
+ SqlBasicFunction.create(SqlKind.ARRAY_POSITION,
+ ReturnTypes.BIGINT_NULLABLE,
+ OperandTypes.ARRAY_ELEMENT);
+
+ /** The "ARRAY_PREPEND(array, element)" function. */
+ @LibraryOperator(libraries = {SPARK})
+ public static final SqlFunction ARRAY_PREPEND =
+ SqlBasicFunction.create(SqlKind.ARRAY_PREPEND,
+ SqlLibraryOperators::arrayAppendPrependReturnType,
+ OperandTypes.ARRAY_ELEMENT);
+
+ /** The "ARRAY_REMOVE(array, element)" function. */
+ @LibraryOperator(libraries = {SPARK})
+ public static final SqlFunction ARRAY_REMOVE =
+ SqlBasicFunction.create(SqlKind.ARRAY_REMOVE,
+ ReturnTypes.ARG0_NULLABLE,
+ OperandTypes.ARRAY_ELEMENT);
Review Comment:
comments:
ARRAY_REMOVE's behavior is also different in spark and flink, just like
array_contains. and i also
add a unit test.
```
// Flink and Spark differ on the following. The expression
// array_remove(array[1, null], cast(null as integer))
// returns [1] in Flink, and returns null in Spark. The current
// function has Spark behavior, but if we supported a Flink function
// library (i.e. "fun=flink") we could add a function with Flink
behavior.
f.checkNull("array_remove(array[1, null], cast(null as integer))");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]