gustavodemorais commented on code in PR #29566:
URL: https://github.com/apache/flink/pull/29566#discussion_r4359467266
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/TypeInferenceUtil.java:
##########
@@ -583,24 +582,32 @@ private static CastCallContext inferInputTypes(
return castCallContext;
}
- private static StateInfo inferStateInfo(
+ private static Optional<StateInfo> inferStateInfo(
CallContext callContext, String name, StateTypeStrategy
stateTypeStrategy) {
final DataType stateType =
stateTypeStrategy.inferType(callContext).orElse(null);
- if (stateType == null || isUnknown(stateType)) {
- final String errorMessage;
+ if (stateType == null) {
+ if (callContext.getFunctionDefinition().getKind() ==
FunctionKind.PROCESS_TABLE) {
Review Comment:
Suggestion: could we add tests for the kept failure paths: an empty
accumulator, a PTF state returning `DataTypes.NULL()`, and a PTF state named
`acc` that is excluded?
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/ptf/BuiltInProcessTableFunction.java:
##########
@@ -76,7 +99,85 @@ protected BuiltInProcessTableFunction(
.orElseThrow(IllegalStateException::new);
this.internalStateStrategies =
- toInternalStateStrategies(definitionTypeInference,
callContext);
+ internalStateStrategies != null
+ ? internalStateStrategies
+ : toInternalStateStrategies(definitionTypeInference);
+ }
+
+ /**
+ * Declares the state entries of a specialized function in order. The
strategies may infer
+ * external data types, they are converted to internal ones.
+ */
+ @SafeVarargs
+ protected static LinkedHashMap<String, StateTypeStrategy> internalState(
Review Comment:
`internalState()` / `customState()` / `toInternalStateStrategy()` are not
used by any built-in PTF and not tested. Will Vas' PR use them? If not, it
might be worth adding one more test.
--
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]