mihaibudiu commented on code in PR #4415:
URL: https://github.com/apache/calcite/pull/4415#discussion_r2145432734


##########
core/src/main/java/org/apache/calcite/sql/SqlArrayTypeNameSpec.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql;
+
+import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+/**
+ * A SqlArrayTypeNameSpec to parse SQL ARRAY type to {@code ARRAY<VARCHAR>}.
+ */
+public class SqlArrayTypeNameSpec extends SqlCollectionTypeNameSpec {
+
+  /**
+   * Creates a {@code SqlArrayTypeNameSpec}.
+   *
+   * @param elementTypeName    Type of the collection element
+   * @param collectionTypeName Collection type name
+   * @param pos                Parser position, must not be null
+   */
+  public SqlArrayTypeNameSpec(SqlTypeNameSpec elementTypeName,

Review Comment:
   This name is confusing, people may think it represents the standard ARRAY 
type.
   You should name it ...ArrayWithAngleBrackets...



##########
core/src/main/java/org/apache/calcite/sql/SqlArrayTypeNameSpec.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql;
+
+import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+/**
+ * A SqlArrayTypeNameSpec to parse SQL ARRAY type to {@code ARRAY<VARCHAR>}.

Review Comment:
   parse or unparse?



##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -191,12 +196,25 @@ public StarRocksSqlDialect(Context context) {
         SqlDataTypeSpec keySpec = (SqlDataTypeSpec) 
getCastSpec(mapSqlType.getKeyType());
         SqlDataTypeSpec valueSpec =
             (SqlDataTypeSpec) getCastSpec(mapSqlType.getValueType());
-        @SuppressWarnings("argument.type.incompatible")
+        SqlDataTypeSpec nonNullKeySpec =
+            requireNonNull(keySpec, "keySpec");
+        SqlDataTypeSpec nonNullValueSpec =
+            requireNonNull(valueSpec, "valueSpec");
         SqlMapTypeNameSpec sqlMapTypeNameSpec =
-            new SqlMapTypeNameSpec(keySpec, valueSpec, SqlParserPos.ZERO);
+            new SqlMapTypeNameSpec(nonNullKeySpec, nonNullValueSpec, 
SqlParserPos.ZERO);
         return new SqlDataTypeSpec(sqlMapTypeNameSpec,
             SqlParserPos.ZERO);
       case ARRAY:
+        ArraySqlType arraySqlType = (ArraySqlType) type;

Review Comment:
   is this the right place to do this transformation?
   For example, this won't affect DDL unparsing (e.g., CREATE TABLE).
   But maybe DDL is out of scope for dialects?



##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9945,7 +9982,6 @@ private void checkLiteral2(String expression, String 
expected) {
     String query = "SELECT CAST(array[1,2,3] AS real array) FROM \"employee\"";
     sql(query)
         .withPhoenix().throws_("Phoenix dialect does not support cast to 
ARRAY")
-        .withStarRocks().throws_("StarRocks dialect does not support cast to 
ARRAY")

Review Comment:
   so it does support such casts?
   



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