[ https://issues.apache.org/jira/browse/FLINK-33217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17799692#comment-17799692 ]
Jane Chan commented on FLINK-33217: ----------------------------------- Sorry for being late. Hi, [~xuyangzhong], thanks for the exploration. While you mentioned that {quote}Because the LEFT join, the type row is forced nullable, and the row type is changes to `ROW(VARCHAR not null)` by `FlinkTypeFactory#createTypeWithNullability` that overrides its super class. And the diff about nullable cases this failure. {quote} Actually, the desired nullability change for the type`ROW(VARCHAR not null) not null` after a LEFT OUTER JOIN should be `ROW(VARCHAR)`, rather than `ROW(VARCHAR not null)`. > Flink SQL: UNNEST fails with on LEFT JOIN with NOT NULL type in array > --------------------------------------------------------------------- > > Key: FLINK-33217 > URL: https://issues.apache.org/jira/browse/FLINK-33217 > Project: Flink > Issue Type: Bug > Components: Table SQL / Planner > Affects Versions: 1.15.3, 1.18.0, 1.19.0 > Reporter: Robert Metzger > Priority: Major > Attachments: UnnestNullErrorTest.scala > > > Steps to reproduce: > Take a column of type > {code:java} > business_data ARRAY<STRING NOT NULL> > {code} > Take this query > {code:java} > select bd_name from reproduce_unnest LEFT JOIN > UNNEST(reproduce_unnest.business_data) AS exploded_bd(bd_name) ON true > {code} > And get this error > {code:java} > Caused by: java.lang.AssertionError: Type mismatch: > rowtype of rel before registration: RecordType(VARCHAR(2147483647) CHARACTER > SET "UTF-16LE" NOT NULL ARRAY business_data, VARCHAR(2147483647) CHARACTER > SET "UTF-16LE" bd_name) NOT NULL > rowtype of rel after registration: RecordType(VARCHAR(2147483647) CHARACTER > SET "UTF-16LE" NOT NULL ARRAY business_data, VARCHAR(2147483647) CHARACTER > SET "UTF-16LE" NOT NULL f0) NOT NULL > Difference: > bd_name: VARCHAR(2147483647) CHARACTER SET "UTF-16LE" -> VARCHAR(2147483647) > CHARACTER SET "UTF-16LE" NOT NULL > at org.apache.calcite.util.Litmus$1.fail(Litmus.java:32) > at org.apache.calcite.plan.RelOptUtil.equal(RelOptUtil.java:2206) > at > org.apache.calcite.rel.AbstractRelNode.onRegister(AbstractRelNode.java:275) > at > org.apache.calcite.plan.volcano.VolcanoPlanner.registerImpl(VolcanoPlanner.java:1270) > at > org.apache.calcite.plan.volcano.VolcanoPlanner.register(VolcanoPlanner.java:598) > at > org.apache.calcite.plan.volcano.VolcanoPlanner.ensureRegistered(VolcanoPlanner.java:613) > at > org.apache.calcite.plan.volcano.VolcanoPlanner.changeTraits(VolcanoPlanner.java:498) > at > org.apache.calcite.tools.Programs$RuleSetProgram.run(Programs.java:315) > at > org.apache.flink.table.planner.plan.optimize.program.FlinkVolcanoProgram.optimize(FlinkVolcanoProgram.scala:62) > {code} > I have implemented a small test case, which fails against Flink 1.15, 1.8 and > the latest master branch. > Workarounds: > 1. Drop "NOT NULL" in array type > 2. Drop "LEFT" from "LEFT JOIN". -- This message was sent by Atlassian Jira (v8.20.10#820010)