juntaozhang commented on PR #26410: URL: https://github.com/apache/flink/pull/26410#issuecomment-2800020978
Let me clarify this issue. I would greatly appreciate it if someone could help review and approve this PR. **Problem Description**: In the expression `SELECT * FROM f(d => INTERVAL '1' SECOND)`, during type cast checking in `TypeInferenceOperandChecker#checkOperandTypes` then `TypeInferenceOperandChecker#insertImplicitCasts` for `DayTimeIntervalType`: - The expectedType is initialized by `DataTypeExtractor#extractPredefinedOrDescriptorType`[code link](https://github.com/apache/flink/blob/master/flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/extraction/DataTypeExtractor.java#L502). If defaultSecondPrecision is null, it defaults to INTERVAL SECOND(9)[code link](https://github.com/apache/flink/blob/master/flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/utils/ClassDataTypeConverter.java#L75). - The actualType is initialized by `FlinkTypeFactory#toLogicalType`, which is hardcoded to `INTERVAL SECOND(3)` [code link](https://github.com/apache/flink/blob/master/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/calcite/FlinkTypeFactory.scala#L620). - The mismatch between expectedType and actualType causes a type conversion from `INTERVAL SECOND(3)` to `INTERVAL SECOND(9)`. During this conversion, Calcite's `SqlTypeUtil#convertTypeToSpec` throws an error: `Unsupported type when convertTypeToSpec: INTERVAL_DAY_SECOND`. **Change**: Similar to `VARCHAR`, `INTERVAL_DAY_TIME` is highly compatible within bounds. To avoid type conversion, add logic in `CastAvoidanceChecker` to handle `INTERVAL_DAY_TIME`. Similar with `YearMonthIntervalType`. -- 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]
