@Override protected Void visitQualifiedNameReference(QualifiedNameReference node, ImmutableList.Builder<Symbol> builder) { builder.add(Symbol.fromQualifiedName(node.getName())); return null; } }
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 QualifiedNameReference) { inputToOutput.put(Symbol.fromQualifiedName(((QualifiedNameReference) assignment.getValue()).getName()), assignment.getKey()); } } return inputToOutput; } }
private static Symbol referenceToSymbol(Expression expression) { checkArgument(expression instanceof QualifiedNameReference); return Symbol.fromQualifiedName(((QualifiedNameReference) expression).getName()); }
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 QualifiedNameReference) { outputToInput.put(assignment.getKey(), Symbol.fromQualifiedName(((QualifiedNameReference) assignment.getValue()).getName())); } } return outputToInput; }
@Override public Expression rewriteQualifiedNameReference(QualifiedNameReference node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { Expression expression = mappings.get(Symbol.fromQualifiedName(node.getName())); checkState(expression != null, "Cannot resolve symbol %s", node.getName()); return expression; } }
@Override public Expression rewriteQualifiedNameReference(QualifiedNameReference node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { Integer channel = symbolToChannelMapping.get(Symbol.fromQualifiedName(node.getName())); Preconditions.checkArgument(channel != null, "Cannot resolve symbol %s", node.getName()); return new InputReference(channel); } }
@Override protected Object visitQualifiedNameReference(QualifiedNameReference node, Object context) { if (node.getName().getPrefix().isPresent()) { // not a symbol return node; } Symbol symbol = Symbol.fromQualifiedName(node.getName()); return ((SymbolResolver) context).getValue(symbol); }
@Override public Expression rewriteQualifiedNameReference(QualifiedNameReference node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { Symbol canonical = canonicalize(Symbol.fromQualifiedName(node.getName())); return new QualifiedNameReference(canonical.toQualifiedName()); } }, value);
private AccumulatorFactory buildAccumulatorFactory( PhysicalOperation source, Signature function, FunctionCall call, @Nullable Symbol mask, Optional<Integer> defaultMaskChannel, Optional<Symbol> sampleWeight, double confidence) { List<Integer> arguments = new ArrayList<>(); for (Expression argument : call.getArguments()) { Symbol argumentSymbol = Symbol.fromQualifiedName(((QualifiedNameReference) argument).getName()); arguments.add(source.getLayout().get(argumentSymbol)); } Optional<Integer> maskChannel = defaultMaskChannel; if (mask != null) { maskChannel = Optional.of(source.getLayout().get(mask)); } Optional<Integer> sampleWeightChannel = Optional.empty(); if (sampleWeight.isPresent()) { sampleWeightChannel = Optional.of(source.getLayout().get(sampleWeight.get())); } return metadata.getFunctionRegistry().getAggregateFunctionImplementation(function).bind(arguments, maskChannel, sampleWeightChannel, confidence); }
public static boolean isCountConstant(ProjectNode projectNode, FunctionCall functionCall, Signature signature) { if (!"count".equals(signature.getName()) || signature.getArgumentTypes().size() != 1 || !signature.getReturnType().getBase().equals(StandardTypes.BIGINT)) { return false; } Expression argument = functionCall.getArguments().get(0); if (argument instanceof Literal && !(argument instanceof NullLiteral)) { return true; } if (argument instanceof QualifiedNameReference) { QualifiedNameReference qualifiedNameReference = (QualifiedNameReference) argument; QualifiedName qualifiedName = qualifiedNameReference.getName(); Symbol argumentSymbol = Symbol.fromQualifiedName(qualifiedName); Expression argumentExpression = projectNode.getAssignments().get(argumentSymbol); return (argumentExpression instanceof Literal) && (!(argumentExpression instanceof NullLiteral)); } return false; } }
Symbol symbol = Symbol.fromQualifiedName(((QualifiedNameReference) expression).getName()); if (!symbol.equals(entry.getKey())) { map(entry.getKey(), symbol);
Symbol symbol = Symbol.fromQualifiedName(((QualifiedNameReference) value).getName()); NullableValue existingConstantValue = constants.get(symbol); if (existingConstantValue != null) {
.map(outputToInputMap::get) .forEach(nameReference -> { Symbol symbol = Symbol.fromQualifiedName(nameReference.getName()); projections.put(symbol, nameReference); inputs.add(symbol);
@Override protected ExtractionResult visitComparisonExpression(ComparisonExpression node, Boolean complement) { Optional<NormalizedSimpleComparison> optionalNormalized = toNormalizedSimpleComparison(session, metadata, types, node); if (!optionalNormalized.isPresent()) { return super.visitComparisonExpression(node, complement); } NormalizedSimpleComparison normalized = optionalNormalized.get(); Symbol symbol = Symbol.fromQualifiedName(normalized.getNameReference().getName()); Type fieldType = checkedTypeLookup(symbol); NullableValue value = normalized.getValue(); // when the field is BIGINT and the value is DOUBLE, transform the expression in such a way that // the semantics are preserved while doing the comparisons in terms of double // TODO: figure out a way to generalize this for other types if (value.getType().equals(DOUBLE) && fieldType.equals(BIGINT)) { return process(coerceDoubleToLongComparison(normalized), complement); } Optional<NullableValue> coercedValue = coerce(value, fieldType); if (!coercedValue.isPresent()) { return super.visitComparisonExpression(node, complement); } return createComparisonExtractionResult(normalized.getComparisonType(), symbol, fieldType, coercedValue.get().getValue(), complement); }
@Override protected ExtractionResult visitIsNotNullPredicate(IsNotNullPredicate node, Boolean complement) { if (!(node.getValue() instanceof QualifiedNameReference)) { return super.visitIsNotNullPredicate(node, complement); } Symbol symbol = Symbol.fromQualifiedName(((QualifiedNameReference) node.getValue()).getName()); Type columnType = checkedTypeLookup(symbol); Domain domain = complementIfNecessary(Domain.notNull(columnType), complement); return new ExtractionResult( TupleDomain.withColumnDomains(ImmutableMap.of(symbol, domain)), TRUE_LITERAL); }
@Override protected ExtractionResult visitIsNullPredicate(IsNullPredicate node, Boolean complement) { if (!(node.getValue() instanceof QualifiedNameReference)) { return super.visitIsNullPredicate(node, complement); } Symbol symbol = Symbol.fromQualifiedName(((QualifiedNameReference) node.getValue()).getName()); Type columnType = checkedTypeLookup(symbol); Domain domain = complementIfNecessary(Domain.onlyNull(columnType), complement); return new ExtractionResult( TupleDomain.withColumnDomains(ImmutableMap.of(symbol, domain)), TRUE_LITERAL); }
if (expression instanceof QualifiedNameReference) { Symbol reference = Symbol.fromQualifiedName(((QualifiedNameReference) expression).getName()); function = ProjectionFunctions.singleColumn(context.getTypes().get(reference), sourceLayout.get(reference));