davidradl commented on code in PR #27330:
URL: https://github.com/apache/flink/pull/27330#discussion_r2603545971
##########
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)) {
+ return Optional.of(indexType);
+ } else {
+ return callContext.fail(
+ throwOnFailure,
+ "Variant values can only be accessed with a CHARACTER
STRING key or indexed with an INTEGER NUMERIC index.");
Review Comment:
can we include what type was given.
nit: wording suggestion - not need to take unless you want to.
Incorrect type {} supplied for the variant value. Variant values can only be
accessed with a CHARACTER STRING map key or an INTEGER NUMERIC array index.
--
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]