chucheng92 commented on code in PR #3579:
URL: https://github.com/apache/calcite/pull/3579#discussion_r1424822417


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10537,6 +10537,29 @@ private static void 
checkArrayConcatAggFuncFails(SqlOperatorFixture t) {
         "[null, foo]", "CHAR(3) ARRAY NOT NULL");
     f2.checkScalar("array(null)",
         "[null]", "NULL ARRAY NOT NULL");
+    // check complex type
+    f2.checkScalar("array(row(1))", "[{1}]",
+        "RecordType(INTEGER NOT NULL EXPR$0) NOT NULL ARRAY NOT NULL");
+    f2.checkScalar("array(row(1, null))", "[{1, null}]",
+        "RecordType(INTEGER NOT NULL EXPR$0, NULL EXPR$1) NOT NULL ARRAY NOT 
NULL");
+    f2.checkScalar("array(row(null, 1))", "[{null, 1}]",
+        "RecordType(NULL EXPR$0, INTEGER NOT NULL EXPR$1) NOT NULL ARRAY NOT 
NULL");
+    f2.checkScalar("array(row(1, 2))", "[{1, 2}]",
+        "RecordType(INTEGER NOT NULL EXPR$0, INTEGER NOT NULL EXPR$1) NOT NULL 
ARRAY NOT NULL");
+    f2.checkFails("^array(row(1, 2), null)^",
+        "Parameters must be of the same type", false);
+    f2.checkFails("^array(null, row(1, 2))^",

Review Comment:
   thanks mihai. you are right. the typechecking has a bug.
   I have tested the calcite std array constructor and spark sql, it shows like 
below:
   
   ```
   0: jdbc:calcite:model=src/test/resources/mode> select array[row(1,2), null];
   +----------------+
   |     EXPR$0     |
   +----------------+
   | [{1, 2}, null] |
   +----------------+
   ```
   
   ```
   spark-sql (default)> select array((1,2), null);
   [{"col1":1,"col2":2},null]
   ```
   
   It is indeed supported this form. 
   
   Considering this bug has always existed and is not the problem to be solved 
by this issue. I will open another issue to tracking/fixing this. WDYT?



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