JinkunLiu commented on code in PR #27330:
URL: https://github.com/apache/flink/pull/27330#discussion_r2721377941
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ItemAtIndexArgumentTypeStrategy.java:
##########
@@ -86,12 +89,36 @@ public Optional<DataType> inferArgumentType(
}
}
+ if (collectionType.is(LogicalTypeRoot.VARIANT)) {
+ if
(indexType.getLogicalType().is(LogicalTypeFamily.INTEGER_NUMERIC)) {
+
+ if (callContext.isArgumentLiteral(1)) {
+ Optional<Integer> literalVal =
callContext.getArgumentValue(1, Integer.class);
+ if (literalVal.isPresent() && literalVal.get() <= 0) {
+ return callContext.fail(
+ throwOnFailure,
+ "The provided index must be a valid SQL index
starting from 1, but was '%s'",
+ literalVal.get());
+ }
+ }
+
+ return Optional.of(indexType);
+ } else if
(indexType.getLogicalType().is(LogicalTypeFamily.CHARACTER_STRING)) {
Review Comment:
Thanks for your advice. I think using LogicalType.typeRoot and
LogicalTypeFamily is a better way to classify types, because it aligns better
with the abstraction level of Flink\’s type system and is more standard and
maintainable.
At the same time, the CHARACTER_STRING family can cover string types such as
CHAR and VARCHAR.
--
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]