@Override protected Void visitSymbolReference(SymbolReference node, ImmutableList.Builder<Symbol> builder) { builder.add(Symbol.from(node)); return null; } }
private static Map<Symbol, Symbol> computeIdentityTranslations(Map<Symbol, Expression> assignments) { Map<Symbol, Symbol> outputToInput = new HashMap<>(); for (Map.Entry<Symbol, Expression> assignment : assignments.entrySet()) { if (assignment.getValue() instanceof SymbolReference) { outputToInput.put(assignment.getKey(), Symbol.from(assignment.getValue())); } } return outputToInput; } }
private static Map<Symbol, Symbol> computeIdentityTranslations(Map<Symbol, Expression> assignments) { Map<Symbol, Symbol> inputToOutput = new HashMap<>(); for (Map.Entry<Symbol, Expression> assignment : assignments.entrySet()) { if (assignment.getValue() instanceof SymbolReference) { inputToOutput.put(Symbol.from(assignment.getValue()), assignment.getKey()); } } return inputToOutput; } }
private static Map<Symbol, Symbol> computeIdentityTranslations(Map<Symbol, Expression> assignments) { Map<Symbol, Symbol> inputToOutput = new HashMap<>(); for (Map.Entry<Symbol, Expression> assignment : assignments.entrySet()) { if (assignment.getValue() instanceof SymbolReference) { inputToOutput.put(Symbol.from(assignment.getValue()), assignment.getKey()); } } return inputToOutput; }
public Symbol getColumn() { verify(expression instanceof SymbolReference, "Expect the expression to be a SymbolReference"); return Symbol.from(expression); }
@Override protected SymbolStatsEstimate visitSymbolReference(SymbolReference node, Void context) { return input.getSymbolStatistics(Symbol.from(node)); }
@Override protected Object visitSymbolReference(SymbolReference node, Object context) { return ((SymbolResolver) context).getValue(Symbol.from(node)); }
@Override public Expression rewriteSymbolReference(SymbolReference node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { Symbol canonical = canonicalize(Symbol.from(node)); return canonical.toSymbolReference(); } }, value);
private static Map<Symbol, Symbol> computeIdentityTranslations(Assignments assignments) { Map<Symbol, Symbol> outputToInput = new HashMap<>(); for (Map.Entry<Symbol, Expression> assignment : assignments.getMap().entrySet()) { if (assignment.getValue() instanceof SymbolReference) { outputToInput.put(assignment.getKey(), Symbol.from(assignment.getValue())); } } return outputToInput; }
@Override public Expression rewriteSymbolReference(SymbolReference node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { if (excludedNames.contains(node.getName())) { return node; } Expression expression = mapping.apply(Symbol.from(node)); checkState(expression != null, "Cannot resolve symbol %s", node.getName()); return expression; }
private SymbolStatsEstimate getExpressionStats(Expression expression) { if (expression instanceof SymbolReference) { Symbol symbol = Symbol.from(expression); return requireNonNull(input.getSymbolStatistics(symbol), () -> format("No statistics for symbol %s", symbol)); } return scalarStatsCalculator.calculate(expression, input, session, types); }
private static EquiJoinClause toEquiJoinClause(ComparisonExpression equality, Set<Symbol> leftSymbols) { Symbol leftSymbol = Symbol.from(equality.getLeft()); Symbol rightSymbol = Symbol.from(equality.getRight()); EquiJoinClause equiJoinClause = new EquiJoinClause(leftSymbol, rightSymbol); return leftSymbols.contains(leftSymbol) ? equiJoinClause : equiJoinClause.flip(); }
@Override public Expression rewriteSymbolReference(SymbolReference node, Context context, ExpressionTreeRewriter<Context> treeRewriter) { Integer channel = symbolToChannelMapping.get(Symbol.from(node)); if (channel == null) { Preconditions.checkArgument(context.isInLambda(), "Cannot resolve symbol %s", node.getName()); return node; } return new FieldReference(channel); }
private Symbol symbolForExpression(Expression expression) { if (expression instanceof SymbolReference) { return Symbol.from(expression); } return symbolAllocator.newSymbol(expression, extractType(expression)); }
@Override public Expression rewriteSymbolReference(SymbolReference node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { Symbol canonical = map(Symbol.from(node)); return canonical.toSymbolReference(); } }, value);
public ArgumentBinding translate(Function<Symbol, Symbol> translator) { if (isConstant()) { return this; } return expressionBinding(translator.apply(Symbol.from(expression)).toSymbolReference()); }
public Symbol toSymbol(SymbolAliases aliases) { return Symbol.from(aliases.get(alias)); }
@Override protected Type visitSymbolReference(SymbolReference node, StackableAstVisitorContext<Context> context) { if (context.getContext().isInLambda()) { Optional<ResolvedField> resolvedField = context.getContext().getScope().tryResolveField(node, QualifiedName.of(node.getName())); if (resolvedField.isPresent() && context.getContext().getFieldToLambdaArgumentDeclaration().containsKey(FieldId.from(resolvedField.get()))) { return setExpressionType(node, resolvedField.get().getType()); } } Type type = symbolTypes.get(Symbol.from(node)); return setExpressionType(node, type); }
@Override protected ExtractionResult visitIsNotNullPredicate(IsNotNullPredicate node, Boolean complement) { if (!(node.getValue() instanceof SymbolReference)) { return super.visitIsNotNullPredicate(node, complement); } Symbol symbol = Symbol.from(node.getValue()); Type columnType = checkedTypeLookup(symbol); Domain domain = complementIfNecessary(Domain.notNull(columnType), complement); return new ExtractionResult( TupleDomain.withColumnDomains(ImmutableMap.of(symbol, domain)), TRUE_LITERAL); }
@Override protected PlanNodeStatsEstimate visitIsNotNullPredicate(IsNotNullPredicate node, Void context) { if (node.getValue() instanceof SymbolReference) { Symbol symbol = Symbol.from(node.getValue()); SymbolStatsEstimate symbolStats = input.getSymbolStatistics(symbol); PlanNodeStatsEstimate.Builder result = PlanNodeStatsEstimate.buildFrom(input); result.setOutputRowCount(input.getOutputRowCount() * (1 - symbolStats.getNullsFraction())); result.addSymbolStatistics(symbol, symbolStats.mapNullsFraction(x -> 0.0)); return result.build(); } return PlanNodeStatsEstimate.unknown(); }