xiedeyantu commented on code in PR #4406:
URL: https://github.com/apache/calcite/pull/4406#discussion_r2126680938
##########
core/src/main/java/org/apache/calcite/sql/dialect/PrestoSqlDialect.java:
##########
@@ -248,7 +289,7 @@ public static void unparseMapValue(SqlWriter writer,
SqlCall call,
*/
public static SqlCall convertMapValueCall(SqlCall call) {
boolean unnestMap = call.operandCount() > 0
- && call.getOperandList().stream().allMatch(operand -> operand
instanceof SqlLiteral);
+ && call.getOperandList().get(0) instanceof SqlLiteral;
Review Comment:
What if only `call.getOperandList().get(1)` is `SqlLiteral`?
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9796,6 +9796,73 @@ private void checkLiteral2(String expression, String
expected) {
.withTrino().ok(expected);
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-7048">[CALCITE-7048]
+ * The specified type conversion does not support complex types in
Presto</a>. */
+ @Test void testPrestoFloatingPointNestedTypesCast() {
Review Comment:
Maybe you should add a test for `MAP[MAP[3.0,4.0], 1.0]`.
##########
core/src/main/java/org/apache/calcite/sql/dialect/PrestoSqlDialect.java:
##########
@@ -178,18 +184,53 @@ private static void unparseUsingLimit(SqlWriter writer,
@Nullable SqlNode offset
}
@Override public @Nullable SqlNode getCastSpec(RelDataType type) {
- switch (type.getSqlTypeName()) {
- // PRESTO only supports REALăDOUBLE for floating point types.
- case FLOAT:
- return new SqlDataTypeSpec(
- new SqlBasicTypeNameSpec(SqlTypeName.DOUBLE, SqlParserPos.ZERO),
SqlParserPos.ZERO);
- // https://prestodb.io/docs/current/language/types.html#varbinary
- case BINARY:
- return new SqlDataTypeSpec(
- new SqlBasicTypeNameSpec(SqlTypeName.VARBINARY, SqlParserPos.ZERO),
SqlParserPos.ZERO);
- default:
- return super.getCastSpec(type);
+ if (type instanceof BasicSqlType) {
Review Comment:
Do we need to make additional judgments about `BasicSqlType ` and
`AbstractSqlType `?
--
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]