public static ExpressionAnalyzer createConstantAnalyzer(Metadata metadata, Session session, List<Expression> parameters, WarningCollector warningCollector) { return createWithoutSubqueries( metadata.getFunctionRegistry(), metadata.getTypeManager(), session, parameters, EXPRESSION_NOT_CONSTANT, "Constant expression cannot contain a subquery", warningCollector, false); }
public static ExpressionAnalyzer createConstantAnalyzer(Metadata metadata, Session session, List<Expression> parameters, WarningCollector warningCollector, boolean isDescribe) { return createWithoutSubqueries( metadata.getFunctionRegistry(), metadata.getTypeManager(), session, parameters, EXPRESSION_NOT_CONSTANT, "Constant expression cannot contain a subquery", warningCollector, isDescribe); }
public static ExpressionAnalyzer createConstantAnalyzer(Metadata metadata, Session session, List<Expression> parameters, WarningCollector warningCollector, boolean isDescribe) { return createWithoutSubqueries( metadata.getFunctionRegistry(), metadata.getTypeManager(), session, parameters, EXPRESSION_NOT_CONSTANT, "Constant expression cannot contain a subquery", warningCollector, isDescribe); }
public static ExpressionAnalyzer createConstantAnalyzer(Metadata metadata, Session session, List<Expression> parameters, WarningCollector warningCollector) { return createWithoutSubqueries( metadata.getFunctionRegistry(), metadata.getTypeManager(), session, parameters, EXPRESSION_NOT_CONSTANT, "Constant expression cannot contain a subquery", warningCollector, false); }
private Map<NodeRef<Expression>, Type> getExpressionTypes(Session session, Expression expression, TypeProvider types) { ExpressionAnalyzer expressionAnalyzer = ExpressionAnalyzer.createWithoutSubqueries( metadata.getFunctionRegistry(), metadata.getTypeManager(), session, types, emptyList(), node -> new IllegalStateException("Unexpected node: %s" + node), WarningCollector.NOOP, false); expressionAnalyzer.analyze(expression, Scope.create()); return expressionAnalyzer.getExpressionTypes(); }
private Map<NodeRef<Expression>, Type> getExpressionTypes(Session session, Expression expression, TypeProvider types) { ExpressionAnalyzer expressionAnalyzer = ExpressionAnalyzer.createWithoutSubqueries( metadata.getFunctionRegistry(), metadata.getTypeManager(), session, types, emptyList(), node -> new IllegalStateException("Unexpected node: %s" + node), WarningCollector.NOOP, false); expressionAnalyzer.analyze(expression, Scope.create()); return expressionAnalyzer.getExpressionTypes(); }
private Map<NodeRef<Expression>, Type> getExpressionTypes(Session session, Expression expression, TypeProvider types) { ExpressionAnalyzer expressionAnalyzer = ExpressionAnalyzer.createWithoutSubqueries( metadata.getFunctionRegistry(), metadata.getTypeManager(), session, types, emptyList(), node -> new IllegalStateException("Unexpected node: %s" + node), WarningCollector.NOOP, false); expressionAnalyzer.analyze(expression, Scope.create()); return expressionAnalyzer.getExpressionTypes(); }
private Map<NodeRef<Expression>, Type> getExpressionTypes(Session session, Expression expression, TypeProvider types) { ExpressionAnalyzer expressionAnalyzer = ExpressionAnalyzer.createWithoutSubqueries( metadata.getFunctionRegistry(), metadata.getTypeManager(), session, types, emptyList(), node -> new IllegalStateException("Unexpected node: %s" + node), WarningCollector.NOOP, false); expressionAnalyzer.analyze(expression, Scope.create()); return expressionAnalyzer.getExpressionTypes(); }
private Type getType(Expression expression) { if (expression instanceof SymbolReference) { Symbol symbol = Symbol.from(expression); return requireNonNull(types.get(symbol), () -> format("No type for symbol %s", symbol)); } ExpressionAnalyzer expressionAnalyzer = ExpressionAnalyzer.createWithoutSubqueries( metadata.getFunctionRegistry(), metadata.getTypeManager(), session, types, ImmutableList.of(), // At this stage, there should be no subqueries in the plan. node -> new VerifyException("Unexpected subquery"), WarningCollector.NOOP, false); return expressionAnalyzer.analyze(expression, Scope.create()); }
private Type getType(Expression expression) { if (expression instanceof SymbolReference) { Symbol symbol = Symbol.from(expression); return requireNonNull(types.get(symbol), () -> format("No type for symbol %s", symbol)); } ExpressionAnalyzer expressionAnalyzer = ExpressionAnalyzer.createWithoutSubqueries( metadata.getFunctionRegistry(), metadata.getTypeManager(), session, types, ImmutableList.of(), // At this stage, there should be no subqueries in the plan. node -> new VerifyException("Unexpected subquery"), WarningCollector.NOOP, false); return expressionAnalyzer.analyze(expression, Scope.create()); }
private static class Context { private final Scope scope; // functionInputTypes and nameToLambdaDeclarationMap can be null or non-null independently. All 4 combinations are possible. // The list of types when expecting a lambda (i.e. processing lambda parameters of a function); null otherwise. // Empty list represents expecting a lambda with no arguments. private final List<Type> functionInputTypes; // The mapping from names to corresponding lambda argument declarations when inside a lambda; null otherwise. // Empty map means that the all lambda expressions surrounding the current node has no arguments. private final Map<FieldId, LambdaArgumentDeclaration> fieldToLambdaArgumentDeclaration; private Context( Scope scope, List<Type> functionInputTypes, Map<FieldId, LambdaArgumentDeclaration> fieldToLambdaArgumentDeclaration) { this.scope = requireNonNull(scope, "scope is null"); this.functionInputTypes = functionInputTypes; this.fieldToLambdaArgumentDeclaration = fieldToLambdaArgumentDeclaration; } public static Context notInLambda(Scope scope) { return new Context(scope, null, null); } public static Context inLambda(Scope scope, Map<FieldId, LambdaArgumentDeclaration> fieldToLambdaArgumentDeclaration) {
private static class Context { private final Scope scope; // functionInputTypes and nameToLambdaDeclarationMap can be null or non-null independently. All 4 combinations are possible. // The list of types when expecting a lambda (i.e. processing lambda parameters of a function); null otherwise. // Empty list represents expecting a lambda with no arguments. private final List<Type> functionInputTypes; // The mapping from names to corresponding lambda argument declarations when inside a lambda; null otherwise. // Empty map means that the all lambda expressions surrounding the current node has no arguments. private final Map<FieldId, LambdaArgumentDeclaration> fieldToLambdaArgumentDeclaration; private Context( Scope scope, List<Type> functionInputTypes, Map<FieldId, LambdaArgumentDeclaration> fieldToLambdaArgumentDeclaration) { this.scope = requireNonNull(scope, "scope is null"); this.functionInputTypes = functionInputTypes; this.fieldToLambdaArgumentDeclaration = fieldToLambdaArgumentDeclaration; } public static Context notInLambda(Scope scope) { return new Context(scope, null, null); } public static Context inLambda(Scope scope, Map<FieldId, LambdaArgumentDeclaration> fieldToLambdaArgumentDeclaration) {
private Map<NodeRef<Expression>, Type> getExpressionTypes(Expression expression) { ExpressionAnalyzer expressionAnalyzer = ExpressionAnalyzer.createWithoutSubqueries( metadata.getFunctionRegistry(), metadata.getTypeManager(), TEST_SESSION, TypeProvider.empty(), emptyList(), node -> new IllegalStateException("Unexpected node: %s" + node), WarningCollector.NOOP, false); expressionAnalyzer.analyze(expression, Scope.create()); return expressionAnalyzer.getExpressionTypes(); } }
private Map<NodeRef<Expression>, Type> getExpressionTypes(Expression expression) { ExpressionAnalyzer expressionAnalyzer = ExpressionAnalyzer.createWithoutSubqueries( metadata.getFunctionRegistry(), metadata.getTypeManager(), TEST_SESSION, TypeProvider.empty(), emptyList(), node -> new IllegalStateException("Unexpected node: %s" + node), WarningCollector.NOOP, false); expressionAnalyzer.analyze(expression, Scope.create()); return expressionAnalyzer.getExpressionTypes(); } }