[ https://issues.apache.org/jira/browse/FLINK-27438?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17529349#comment-17529349 ]
Wei Zhong commented on FLINK-27438: ----------------------------------- Thanks for your reply. It was discovered when we migrated some test code from 1.13 to 1.15. The sql works well on 1.13. > SQL validation failed when constructing a map array > --------------------------------------------------- > > Key: FLINK-27438 > URL: https://issues.apache.org/jira/browse/FLINK-27438 > Project: Flink > Issue Type: Bug > Components: Table SQL / Planner > Affects Versions: 1.15.0, 1.14.4 > Reporter: Wei Zhong > Priority: Major > > Exception: > {code:java} > Exception in thread "main" org.apache.flink.table.api.ValidationException: > SQL validation failed. Unsupported type when convertTypeToSpec: MAP > at > org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$validate(FlinkPlannerImpl.scala:185) > at > org.apache.flink.table.planner.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:110) > at > org.apache.flink.table.planner.operations.SqlToOperationConverter.convert(SqlToOperationConverter.java:237) > at > org.apache.flink.table.planner.delegation.ParserImpl.parse(ParserImpl.java:105) > at > org.apache.flink.table.api.internal.TableEnvironmentImpl.executeSql(TableEnvironmentImpl.java:695) > at > org.apache.flink.table.planner.plan.stream.sql.LegacyTableFactoryTest.<init>(LegacyTableFactoryTest.java:35) > at > org.apache.flink.table.planner.plan.stream.sql.LegacyTableFactoryTest.main(LegacyTableFactoryTest.java:49) > Caused by: java.lang.UnsupportedOperationException: Unsupported type when > convertTypeToSpec: MAP > at > org.apache.calcite.sql.type.SqlTypeUtil.convertTypeToSpec(SqlTypeUtil.java:1059) > at > org.apache.calcite.sql.type.SqlTypeUtil.convertTypeToSpec(SqlTypeUtil.java:1081) > at > org.apache.flink.table.planner.functions.utils.SqlValidatorUtils.castTo(SqlValidatorUtils.java:82) > at > org.apache.flink.table.planner.functions.utils.SqlValidatorUtils.adjustTypeForMultisetConstructor(SqlValidatorUtils.java:74) > at > org.apache.flink.table.planner.functions.utils.SqlValidatorUtils.adjustTypeForArrayConstructor(SqlValidatorUtils.java:39) > at > org.apache.flink.table.planner.functions.sql.SqlArrayConstructor.inferReturnType(SqlArrayConstructor.java:44) > at > org.apache.calcite.sql.SqlOperator.validateOperands(SqlOperator.java:449) > at org.apache.calcite.sql.SqlOperator.deriveType(SqlOperator.java:531) > at > org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5716) > at > org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5703) > at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1736) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1727) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:421) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4061) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3347) > at > org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60) > at > org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:997) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:975) > at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:232) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:952) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:704) > at > org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$validate(FlinkPlannerImpl.scala:180) > ... 6 more {code} > How to reproduce: > {code:java} > tableEnv.executeSql("select array[map['A', 'AA'], map['B', 'BB'], map['C', > CAST(NULL AS STRING)]] from (VALUES ('a'))").print(); {code} -- This message was sent by Atlassian Jira (v8.20.7#820007)