davidradl commented on code in PR #27330:
URL: https://github.com/apache/flink/pull/27330#discussion_r2603527093
##########
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.");
+ }
+ }
+
return Optional.empty();
}
@Override
public Signature.Argument getExpectedArgument(
FunctionDefinition functionDefinition, int argumentPos) {
- return Signature.Argument.of("[<INTEGER NUMERIC> | <MAP_KEY_TYPE>]");
+ return Signature.Argument.of(
+ "[<INTEGER NUMERIC> | <MAP_KEY_TYPE> | <CHARACTER STRING> or
<INTEGER NUMERIC>]");
Review Comment:
Why do we need `<INTEGER NUMERIC>` twice here?
--
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]