lvyanquan commented on code in PR #4496:
URL: https://github.com/apache/flink-cdc/pull/4496#discussion_r3712478901
##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/typeutils/CalciteDataTypeConverter.java:
##########
@@ -339,6 +339,10 @@ public static DataType
convertCalciteRelDataTypeToDataType(RelDataType relDataTy
case VARIANT:
return DataTypes.VARIANT();
case ROW:
+ return DataTypes.ROW(
+ relDataType.getFieldList().stream()
+ .map(field ->
convertCalciteRelDataTypeToDataType(field.getType()))
+ .toArray(DataType[]::new));
Review Comment:
Could we preserve the original ROW field names here?
`DataTypes.ROW(DataType...)` regenerates all field names as `f0`, `f1`, etc.
For example, if `complex_row_` is `ROW<name STRING, length INT>`,
`ELEMENT(ARRAY[complex_row_])` will incorrectly produce `ROW<f0 STRING, f1
INT>`. The same issue affects named ROW types nested in ARRAY or MAP and may
change the downstream schema.
Please construct the ROW type using Calciteās field names, while normalizing
Calcite-generated aliases for explicit `ROW(...)` constructors to `f0`, `f1`,
etc. It would also be good to add a regression test covering a named ROW
through `ELEMENT`, ARRAY, or MAP.
--
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]