liuyongvs commented on code in PR #3263:
URL: https://github.com/apache/calcite/pull/3263#discussion_r1241077051


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5594,6 +5619,90 @@ private static void checkIf(SqlOperatorFixture f) {
     f.checkNull("array_union(cast(null as integer array), cast(null as integer 
array))");
   }
 
+  /** Tests {@code ARRAYS_OVERLAP} function from Spark. */
+  @Test void testArraysOverlapFunc() {
+    final SqlOperatorFixture f0 = fixture();
+    f0.setFor(SqlLibraryOperators.ARRAYS_OVERLAP);
+    f0.checkFails("^arrays_overlap(array[1, 2], array[2])^",
+        "No match found for function signature ARRAYS_OVERLAP\\("
+            + "<INTEGER ARRAY>, <INTEGER ARRAY>\\)", false);
+
+    final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.SPARK);
+    f.checkScalar("arrays_overlap(array[1, 2], array[2])", true,
+        "BOOLEAN NOT NULL");
+    f.checkScalar("arrays_overlap(array[1, 2], array[3])", false,
+        "BOOLEAN NOT NULL");
+    f.checkScalar("arrays_overlap(array[1, null], array[1])", true,

Review Comment:
   yeap @NobiGo 
   1) 
   array[1, null] -> type is INT ARRAY NOT NULL
   array[1] -> type is INT NOT NULL ARRAY NOT NULL
   so the type is boolean
   
   ```
   case class ArraysOverlap(left: Expression, right: Expression)
     override def nullable: Boolean = {
       left.nullable || right.nullable || leftArrayElementNullable || 
rightArrayElementNullable
     }
   ```
   
   2) spark/postgres's typeof doesn't display not null/null info, but 
calcite/flink does. so the spark display it not full.
   we should confirm the behavior by code
   
    you can look here https://issues.apache.org/jira/browse/FLINK-31906
   
   ```
   spark-sql (default)> select typeof(arrays_overlap(array(1, null), array(1)));
   boolean
   
   spark-sql (default)> select typeof(arrays_overlap(array(1), array(1)));
   boolean // don't display not null info.
   ```
   



-- 
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]

Reply via email to