liuyongvs commented on code in PR #19873:
URL: https://github.com/apache/flink/pull/19873#discussion_r1149154760


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/BuiltInFunctionDefinitions.java:
##########
@@ -178,6 +179,35 @@ ANY, and(logical(LogicalTypeRoot.BOOLEAN), LITERAL)
                     .runtimeClass(
                             
"org.apache.flink.table.runtime.functions.scalar.ArrayDistinctFunction")
                     .build();
+
+    public static final BuiltInFunctionDefinition ARRAY_APPEND =
+            BuiltInFunctionDefinition.newBuilder()
+                    .name("ARRAY_APPEND")
+                    .kind(SCALAR)
+                    .inputTypeStrategy(
+                            sequence(
+                                    Arrays.asList("haystack", "element"),
+                                    Arrays.asList(
+                                            logical(LogicalTypeRoot.ARRAY), 
ARRAY_ELEMENT_ARG)))
+                    .outputTypeStrategy(nullableIfArgs(argument(0)))
+                    .runtimeClass(
+                            
"org.apache.flink.table.runtime.functions.scalar.ArrayAppendFunction")
+                    .build();

Review Comment:
   i think nullableIfArgs(argument(0)) it is not enough.
   when the element is nullable, the return type nullable should be changed 



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/BuiltInFunctionDefinitions.java:
##########
@@ -178,6 +179,35 @@ ANY, and(logical(LogicalTypeRoot.BOOLEAN), LITERAL)
                     .runtimeClass(
                             
"org.apache.flink.table.runtime.functions.scalar.ArrayDistinctFunction")
                     .build();
+
+    public static final BuiltInFunctionDefinition ARRAY_APPEND =
+            BuiltInFunctionDefinition.newBuilder()
+                    .name("ARRAY_APPEND")
+                    .kind(SCALAR)
+                    .inputTypeStrategy(
+                            sequence(
+                                    Arrays.asList("haystack", "element"),
+                                    Arrays.asList(
+                                            logical(LogicalTypeRoot.ARRAY), 
ARRAY_ELEMENT_ARG)))
+                    .outputTypeStrategy(nullableIfArgs(argument(0)))
+                    .runtimeClass(
+                            
"org.apache.flink.table.runtime.functions.scalar.ArrayAppendFunction")
+                    .build();
+
+    public static final BuiltInFunctionDefinition ARRAY_PREPEND =
+            BuiltInFunctionDefinition.newBuilder()
+                    .name("ARRAY_PREPEND")
+                    .kind(SCALAR)
+                    .inputTypeStrategy(
+                            sequence(
+                                    Arrays.asList("element", "haystack"),
+                                    Arrays.asList(
+                                            ARRAY_ELEMENT_ARG1, 
logical(LogicalTypeRoot.ARRAY))))
+                    .outputTypeStrategy(nullableIfArgs(argument(1)))
+                    .runtimeClass(

Review Comment:
                       .outputTypeStrategy(nullableIfArgs(argument(1))) is not 
correct



##########
docs/data/sql_functions.yml:
##########
@@ -617,6 +617,12 @@ collection:
   - sql: ARRAY_DISTINCT(haystack)
     table: haystack.arrayDistinct()
     description: Returns an array with unique elements. If the array itself is 
null, the function will return null. Keeps ordering of elements.
+  - sql: ARRAY_APPEND(haystack, element)
+    table: haystack.arrayAppend(needle)
+    description: Appends an element to the end of the array and returns the 
result. If the array itself is null, the function will return null. If an 
element to add is null, the null element will be added to the end of the array. 
The given element is cast implicitly to the array's element type if necessary.
+  - sql: ARRAY_PREPEND(element, haystack)
+    table: haystack.arrayPrepend(needle)
+    description: Appends an element to the beginning of the array and returns 
the result. If the array itself is null, the function will return null. If an 
element to add is null, the null element will be added to the beginning of the 
array. The given element is cast implicitly to the array's element type if 
necessary.

Review Comment:
   ARRAY_PREPEND(element, haystack) -> ARRAY_PREPEND(haystack, element) refers  
here https://docs.snowflake.com/en/sql-reference/functions/array_append



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to