twalthr commented on a change in pull request #11081: [FLINK-16033][table-api]
Introduced Java Table API Expression DSL
URL: https://github.com/apache/flink/pull/11081#discussion_r385597494
##########
File path:
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/utils/factories/CalculatedTableFactory.java
##########
@@ -95,42 +94,87 @@ public FunctionTableCallVisitor(String[]
leftTableFieldNames) {
}
CallExpression tableCall = (CallExpression)
children.get(0);
- TableFunctionDefinition tableFunctionDefinition =
- (TableFunctionDefinition)
tableCall.getFunctionDefinition();
- return createFunctionCall(tableFunctionDefinition,
aliases, tableCall.getResolvedChildren());
+ return createFunctionCall(tableCall, aliases);
+ }
+
+ private CalculatedQueryOperation<?>
createFunctionCall(CallExpression call, List<String> aliases) {
+ FunctionDefinition definition =
call.getFunctionDefinition();
+ if (definition instanceof TableFunctionDefinition) {
+ return createFunctionCall(
+ ((TableFunctionDefinition)
definition).getTableFunction(),
+
call.getFunctionIdentifier().orElse(FunctionIdentifier.of(definition.toString())),
+ call.getOutputDataType(),
+ aliases,
+ call.getResolvedChildren());
+ } else if (definition instanceof TableFunction<?>) {
+ return createFunctionCall(
+ (TableFunction<?>) definition,
+
call.getFunctionIdentifier().orElse(FunctionIdentifier.of(definition.toString())),
+ call.getOutputDataType(),
+ aliases,
+ call.getResolvedChildren());
+ } else {
+ return defaultMethod(call);
+ }
}
private CalculatedQueryOperation<?> createFunctionCall(
- TableFunctionDefinition tableFunctionDefinition,
+ TableFunction<?> tableFunction,
+ FunctionIdentifier identifier,
+ DataType resultType,
List<String> aliases,
List<ResolvedExpression> parameters) {
- TypeInformation<?> resultType =
tableFunctionDefinition.getResultType();
- int callArity = resultType.getTotalFields();
- int aliasesSize = aliases.size();
+ final TableSchema tableSchema = adjustNames(
+ extractSchema(resultType),
+ aliases,
+ identifier);
- String[] fieldNames;
+ return new CalculatedQueryOperation(
+ tableFunction,
+ parameters,
+
TypeConversions.fromDataTypeToLegacyInfo(resultType),
Review comment:
Can we store the DataType instead to not loose information 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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services