xuzifu666 commented on code in PR #4290:
URL: https://github.com/apache/calcite/pull/4290#discussion_r2032303970
##########
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java:
##########
@@ -216,6 +216,24 @@ private static SqlDataTypeSpec
createSqlDataTypeSpecByName(String typeAlias,
}
switch (call.getKind()) {
+ case MAP_VALUE_CONSTRUCTOR:
+ writer.print(call.getOperator().getName().toLowerCase(Locale.ROOT));
+ final SqlWriter.Frame mapFrame = writer.startList("(", ")");
+ for (int i = 0; i < call.operandCount(); i++) {
+ writer.sep(",");
+ call.operand(i).unparse(writer, leftPrec, rightPrec);
+ }
+ writer.endList(mapFrame);
+ break;
+ case ARRAY_VALUE_CONSTRUCTOR:
+ writer.print(call.getOperator().getName().toLowerCase(Locale.ROOT));
Review Comment:
the constructor without arguments would error out:
select map[];
```
org.apache.calcite.runtime.CalciteContextException: From line 1, column 8 to
line 1, column 14: Require at least 1 argument
org.apache.calcite.tools.ValidationException:
org.apache.calcite.runtime.CalciteContextException: From line 1, column 8 to
line 1, column 14: Require at least 1 argument
at org.apache.calcite.prepare.PlannerImpl.validate(PlannerImpl.java:228)
at
org.apache.calcite.rel.rel2sql.RelToSqlConverterTest$Sql.exec(RelToSqlConverterTest.java:9964)
at
org.apache.calcite.rel.rel2sql.RelToSqlConverterTest$Sql.ok(RelToSqlConverterTest.java:9930)
at
org.apache.calcite.rel.rel2sql.RelToSqlConverterTest.testEmptyMapValueConstructor(RelToSqlConverterTest.java:9129)
```
select array[];
```
org.apache.calcite.runtime.CalciteContextException: From line 1, column 8 to
line 1, column 12: Map requires at least 2 arguments
org.apache.calcite.tools.ValidationException:
org.apache.calcite.runtime.CalciteContextException: From line 1, column 8 to
line 1, column 12: Map requires at least 2 arguments
at org.apache.calcite.prepare.PlannerImpl.validate(PlannerImpl.java:228)
at
org.apache.calcite.rel.rel2sql.RelToSqlConverterTest$Sql.exec(RelToSqlConverterTest.java:9964)
at
org.apache.calcite.rel.rel2sql.RelToSqlConverterTest$Sql.ok(RelToSqlConverterTest.java:9930)
```
do we need to support constructor without arguments for map/array here?
@mihaibudiu
--
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]