dawidwys commented on a change in pull request #8865: [FLINK-12924][table]
Introduce basic type inference interfaces
URL: https://github.com/apache/flink/pull/8865#discussion_r297080699
##########
File path:
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/expressions/rules/ResolveCallByArgumentsRule.java
##########
@@ -160,10 +234,70 @@ private ResolvedExpression castIfNeeded(
expectedType));
}
}
+ }
+
+ //
--------------------------------------------------------------------------------------------
+
+ private class TableApiCallContext implements CallContext {
+
+ private final String name;
+
+ private final FunctionDefinition definition;
+
+ private final List<ResolvedExpression> resolvedArgs;
+
+ public TableApiCallContext(
+ String name,
+ FunctionDefinition definition,
+ List<ResolvedExpression> resolvedArgs) {
+ this.name = name;
+ this.definition = definition;
+ this.resolvedArgs = resolvedArgs;
+ }
@Override
- protected Expression defaultMethod(Expression expression) {
- return expression;
+ public List<DataType> getArgumentDataTypes() {
+ return resolvedArgs.stream()
+ .map(ResolvedExpression::getOutputDataType)
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public FunctionDefinition getFunctionDefinition() {
+ return definition;
+ }
+
+ @Override
+ public boolean isArgumentLiteral(int pos) {
+ return getArgument(pos) instanceof
ValueLiteralExpression;
+ }
+
+ @Override
+ public boolean isArgumentNull(int pos) {
+ final ValueLiteralExpression literal =
(ValueLiteralExpression) getArgument(pos);
+ return literal.isNull();
+ }
+
+ @Override
+ public <T> Optional<T> getArgumentValue(int pos, Class<T>
clazz) {
+ final ValueLiteralExpression literal =
(ValueLiteralExpression) getArgument(pos);
Review comment:
nit: Maybe check `isArgumentLiteral` just to have a nicer exception?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services