public static ExpressionAnalysis analyzeExpressionsWithSymbols( Session session, Metadata metadata, SqlParser sqlParser, TypeProvider types, Iterable<Expression> expressions, List<Expression> parameters, WarningCollector warningCollector, boolean isDescribe) { return analyzeExpressions(session, metadata, sqlParser, new RelationType(), types, expressions, parameters, warningCollector, isDescribe); }
private static ExpressionAnalysis analyzeExpressionsWithInputs( Session session, Metadata metadata, SqlParser sqlParser, Map<Integer, Type> types, Iterable<Expression> expressions, List<Expression> parameters, WarningCollector warningCollector) { Field[] fields = new Field[types.size()]; for (Entry<Integer, Type> entry : types.entrySet()) { fields[entry.getKey()] = com.facebook.presto.sql.analyzer.Field.newUnqualified(Optional.empty(), entry.getValue()); } RelationType tupleDescriptor = new RelationType(fields); return analyzeExpressions(session, metadata, sqlParser, tupleDescriptor, TypeProvider.empty(), expressions, parameters, warningCollector); }
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 ExpressionAnalysis analyzeExpressionsWithInputs( Session session, Metadata metadata, SqlParser sqlParser, Map<Integer, Type> types, Iterable<? extends Expression> expressions) { Field[] fields = new Field[types.size()]; for (Entry<Integer, Type> entry : types.entrySet()) { fields[entry.getKey()] = Field.newUnqualified(Optional.empty(), entry.getValue()); } RelationType tupleDescriptor = new RelationType(fields); return analyzeExpressions(session, metadata, sqlParser, tupleDescriptor, expressions); }
public static ExpressionAnalysis analyzeExpressionsWithSymbols( Session session, Metadata metadata, SqlParser sqlParser, Map<Symbol, Type> types, Iterable<? extends Expression> expressions) { List<Field> fields = DependencyExtractor.extractUnique(expressions).stream() .map(symbol -> { Type type = types.get(symbol); checkArgument(type != null, "No type for symbol %s", symbol); return Field.newUnqualified(symbol.getName(), type); }) .collect(toImmutableList()); return analyzeExpressions(session, metadata, sqlParser, new RelationType(fields), expressions); }