xuyangzhong commented on PR #23519: URL: https://github.com/apache/flink/pull/23519#issuecomment-1780697786
Hi, @snuyanzin . Thanks for your review. The bug happens only when using the SQL API. The table API will not throw this exception actually. The quick explanation is: - Only when parsing SQL, the struct kind of the computed ROW type will be changed to PEEK_FIELDS_NO_EXPAND by calling FlinkTypeFactory#createFieldTypeFromLogicalType after calling SqlRowOperator. - When using table API, the struct kind of the computed ROW type is always FULLY_QUALIFIED by only calling SqlRowOperator. The following is the detail: After executing DDL 'create table', the struct kind of the computed ROW type is FULLY_QUALIFIED (which is wrong across SqlRowOperator), but Flink always replaces the Calcite RelDataType Row with Flink LogicalType Row and ignores the struct kind as the source schema. When executing the query 'select * from table', Flink will get the source output RelDataType in CatalogSchemaTable#getRowType, where Flink reverts the LogicalType to calcite RelDataType and the RelDataType ROW in Calcite is attached with PEEK_FIELDS_NO_EXPAND in FlinkTypeFactory#createFieldTypeFromLogicalType. However, in source columns, the output RelDataType of the expression "row(a, b)" is still with FULLY_QUALIFIED, which causes the validation to fail later. The table API will not throw this exception. Although table API shares the code about converting the "row(a, b)" to expression and gets the wrong FULLY_QUALIFIED when building source, it lakes the piece about reverting Flink LogicalType to calcite RelDataType in CatalogSchemaTable#getRowType(This is necessary for Calcite parsing & validating) and using the wrong FULLY_QUALIFIED as the final struct kind about Row. I think for fixing this bug, this pr is already. But for more, we need to union the behavior about these two APIs. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org