dawidwys commented on a change in pull request #11280: [FLINK-16377][table] Support inline user defined functions in expression dsl URL: https://github.com/apache/flink/pull/11280#discussion_r397770610
########## File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/utils/factories/CalculatedTableFactory.java ########## @@ -59,82 +59,101 @@ public QueryOperation create(ResolvedExpression callExpr, String[] leftTableFiel return callExpr.accept(calculatedTableCreator); } - private class FunctionTableCallVisitor extends ResolvedExpressionDefaultVisitor<CalculatedQueryOperation<?>> { - - private String[] leftTableFieldNames; + private static class FunctionTableCallVisitor extends ResolvedExpressionDefaultVisitor<CalculatedQueryOperation> { + private List<String> leftTableFieldNames; + private static final String ATOMIC_FIELD_NAME = "f0"; public FunctionTableCallVisitor(String[] leftTableFieldNames) { - this.leftTableFieldNames = leftTableFieldNames; + this.leftTableFieldNames = Arrays.asList(leftTableFieldNames); } @Override - public CalculatedQueryOperation<?> visit(CallExpression call) { + public CalculatedQueryOperation visit(CallExpression call) { FunctionDefinition definition = call.getFunctionDefinition(); if (definition.equals(AS)) { return unwrapFromAlias(call); - } else if (definition instanceof TableFunctionDefinition) { - return createFunctionCall( - (TableFunctionDefinition) definition, - Collections.emptyList(), - call.getResolvedChildren()); - } else { - return defaultMethod(call); } + + return createFunctionCall(call, Collections.emptyList(), call.getResolvedChildren()); } - private CalculatedQueryOperation<?> unwrapFromAlias(CallExpression call) { + private CalculatedQueryOperation unwrapFromAlias(CallExpression call) { List<Expression> children = call.getChildren(); List<String> aliases = children.subList(1, children.size()) .stream() .map(alias -> ExpressionUtils.extractValue(alias, String.class) .orElseThrow(() -> new ValidationException("Unexpected alias: " + alias))) .collect(toList()); - if (!isFunctionOfKind(children.get(0), TABLE)) { + if (!(children.get(0) instanceof CallExpression)) { Review comment: correct ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services