if (coalesceSymbols.containsKey(symbol)) { Expression expression = new CoalesceExpression(symbol.toSymbolReference(), new Cast(new LongLiteral("0"), "bigint")); outputSymbols.put(coalesceSymbols.get(symbol), expression); outputSymbols.putIdentity(symbol); return new ProjectNode(idAllocator.getNextId(), aggregationNode, outputSymbols.build());
leftCoercions.putIdentities(left.getRoot().getOutputSymbols()); rightCoercions.putIdentities(right.getRoot().getOutputSymbols()); for (int i = 0; i < joinColumns.size(); i++) { Identifier identifier = joinColumns.get(i); leftCoercions.put(leftOutput, new Cast( left.getSymbol(leftField).toSymbolReference(), type.getTypeSignature().toString(), rightCoercions.put(rightOutput, new Cast( right.getSymbol(rightField).toSymbolReference(), type.getTypeSignature().toString(), ProjectNode leftCoercion = new ProjectNode(idAllocator.getNextId(), left.getRoot(), leftCoercions.build()); ProjectNode rightCoercion = new ProjectNode(idAllocator.getNextId(), right.getRoot(), rightCoercions.build()); Symbol output = symbolAllocator.newSymbol(column, analysis.getType(column)); outputs.add(output); assignments.put(output, new CoalesceExpression( leftJoinColumns.get(column).toSymbolReference(), rightJoinColumns.get(column).toSymbolReference())); Symbol symbol = left.getFieldMappings().get(field); outputs.add(symbol); assignments.put(symbol, symbol.toSymbolReference()); Symbol symbol = right.getFieldMappings().get(field); outputs.add(symbol); assignments.put(symbol, symbol.toSymbolReference());
.putIdentities(aggregationOutputSymbols) .putAll(subqueryProjection.get().getAssignments()) .build();
leftProjections.putAll(node.getLeft() .getOutputSymbols().stream() .collect(Collectors.toMap(key -> key, Symbol::toSymbolReference))); rightProjections.putAll(node.getRight() .getOutputSymbols().stream() .collect(Collectors.toMap(key -> key, Symbol::toSymbolReference))); leftProjections.put(leftSymbol, leftExpression); rightProjections.put(rightSymbol, rightExpression); !filtersEquivalent || !ImmutableSet.copyOf(equiJoinClauses).equals(ImmutableSet.copyOf(node.getCriteria()))) { leftSource = new ProjectNode(idAllocator.getNextId(), leftSource, leftProjections.build()); rightSource = new ProjectNode(idAllocator.getNextId(), rightSource, rightProjections.build());
leftProjections.putAll(node.getLeft() .getOutputSymbols().stream() .collect(Collectors.toMap(key -> key, Symbol::toSymbolReference))); rightProjections.putAll(node.getRight() .getOutputSymbols().stream() .collect(Collectors.toMap(key -> key, Symbol::toSymbolReference))); leftProjections.put(leftSymbol, leftExpression); rightProjections.put(rightSymbol, rightExpression); !filtersEquivalent || !ImmutableSet.copyOf(equiJoinClauses).equals(ImmutableSet.copyOf(node.getCriteria()))) { leftSource = new ProjectNode(idAllocator.getNextId(), leftSource, leftProjections.build()); rightSource = new ProjectNode(idAllocator.getNextId(), rightSource, rightProjections.build());
if (coalesceSymbols.containsKey(symbol)) { Expression expression = new CoalesceExpression(symbol.toSymbolReference(), new Cast(new LongLiteral("0"), "bigint")); outputSymbols.put(coalesceSymbols.get(symbol), expression); outputSymbols.putIdentity(symbol); return new ProjectNode(idAllocator.getNextId(), aggregationNode, outputSymbols.build());
leftCoercions.putIdentities(left.getRoot().getOutputSymbols()); rightCoercions.putIdentities(right.getRoot().getOutputSymbols()); for (int i = 0; i < joinColumns.size(); i++) { Identifier identifier = joinColumns.get(i); leftCoercions.put(leftOutput, new Cast( left.getSymbol(leftField).toSymbolReference(), type.getTypeSignature().toString(), rightCoercions.put(rightOutput, new Cast( right.getSymbol(rightField).toSymbolReference(), type.getTypeSignature().toString(), ProjectNode leftCoercion = new ProjectNode(idAllocator.getNextId(), left.getRoot(), leftCoercions.build()); ProjectNode rightCoercion = new ProjectNode(idAllocator.getNextId(), right.getRoot(), rightCoercions.build()); Symbol output = symbolAllocator.newSymbol(column, analysis.getType(column)); outputs.add(output); assignments.put(output, new CoalesceExpression( leftJoinColumns.get(column).toSymbolReference(), rightJoinColumns.get(column).toSymbolReference())); Symbol symbol = left.getFieldMappings().get(field); outputs.add(symbol); assignments.put(symbol, symbol.toSymbolReference()); Symbol symbol = right.getFieldMappings().get(field); outputs.add(symbol); assignments.put(symbol, symbol.toSymbolReference());
leftProjections.putAll(node.getLeft() .getOutputSymbols().stream() .collect(Collectors.toMap(key -> key, Symbol::toSymbolReference))); rightProjections.putAll(node.getRight() .getOutputSymbols().stream() .collect(Collectors.toMap(key -> key, Symbol::toSymbolReference))); leftSource = new ProjectNode(idAllocator.getNextId(), leftSource, leftProjections.build()); rightSource = new ProjectNode(idAllocator.getNextId(), rightSource, rightProjections.build());
leftProjections.putAll(node.getLeft() .getOutputSymbols().stream() .collect(Collectors.toMap(key -> key, Symbol::toSymbolReference))); rightProjections.putAll(node.getRight() .getOutputSymbols().stream() .collect(Collectors.toMap(key -> key, Symbol::toSymbolReference))); leftSource = new ProjectNode(idAllocator.getNextId(), leftSource, leftProjections.build()); rightSource = new ProjectNode(idAllocator.getNextId(), rightSource, rightProjections.build());
decorrelatedBuildSource, Assignments.builder() .putIdentities(decorrelatedBuildSource.getOutputSymbols()) .put(buildSideKnownNonNull, bigint(0)) .build()); aggregation, Assignments.builder() .putIdentities(apply.getInput().getOutputSymbols()) .put(inPredicateOutputSymbol, inPredicateEquivalent) .build());
decorrelatedBuildSource, Assignments.builder() .putIdentities(decorrelatedBuildSource.getOutputSymbols()) .put(buildSideKnownNonNull, bigint(0)) .build()); aggregation, Assignments.builder() .putIdentities(apply.getInput().getOutputSymbols()) .put(inPredicateOutputSymbol, inPredicateEquivalent) .build());
.putIdentities(aggregationOutputSymbols) .putAll(subqueryProjection.get().getAssignments()) .build();
Symbol symbol = context.getSymbolAllocator().newSymbol(filter, BOOLEAN); verify(!mask.isPresent(), "Expected aggregation without mask symbols, see Rule pattern"); newAssignments.put(symbol, filter); mask = Optional.of(symbol); newAssignments.putIdentities(aggregation.getSource().getOutputSymbols()); context.getIdAllocator().getNextId(), aggregation.getSource(), newAssignments.build()), predicate), aggregations.build(),
.putAll(assignmentsWithoutTargetOutputIdentities) .putIdentities(targetInputs) .build();
.putAll(assignmentsWithoutTargetOutputIdentities) .putIdentities(targetInputs) .build();
Symbol symbol = context.getSymbolAllocator().newSymbol(filter, BOOLEAN); verify(!mask.isPresent(), "Expected aggregation without mask symbols, see Rule pattern"); newAssignments.put(symbol, filter); mask = Optional.of(symbol); newAssignments.putIdentities(aggregation.getSource().getOutputSymbols()); context.getIdAllocator().getNextId(), aggregation.getSource(), newAssignments.build()), predicate), aggregations.build(),
p.project( Assignments.builder() .put(p.symbol("one"), expression("CAST(1 AS bigint)")) .putIdentities(ImmutableList.of(p.symbol("a"), p.symbol("avgOutput"))) .build(), p.project( Assignments.identity(p.symbol("a"), p.symbol("avgOutput"), p.symbol("unused")),
p.project( Assignments.builder() .put(p.symbol("one"), expression("CAST(1 AS bigint)")) .putIdentities(ImmutableList.of(p.symbol("a"), p.symbol("avgOutput"))) .build(), p.project( Assignments.identity(p.symbol("a"), p.symbol("avgOutput"), p.symbol("unused")),
node.getSource(), Assignments.builder() .putIdentities(node.getSource().getOutputSymbols()) .put(partitionCountSymbol, new LongLiteral(Integer.toString(getHashPartitionCount(context.getSession())))) .putAll(envelopeAssignments.build()) .build()), aggregations.build(), node.getGroupingSets(),
JoinNode.Type.LEFT, p.project(Assignments.builder() .putIdentity(p.symbol("COL1", BIGINT)) .build(), p.aggregation(builder -> builder.singleGroupingSet(p.symbol("COL1"), p.symbol("unused"))