private boolean arePlansSame(FilterNode filter, TableScanNode tableScan, PlanNode rewritten) { if (!(rewritten instanceof FilterNode)) { return false; } FilterNode rewrittenFilter = (FilterNode) rewritten; if (!Objects.equals(filter.getPredicate(), rewrittenFilter.getPredicate())) { return false; } if (!(rewrittenFilter.getSource() instanceof TableScanNode)) { return false; } TableScanNode rewrittenTableScan = (TableScanNode) rewrittenFilter.getSource(); if (!tableScan.getLayout().isPresent() && rewrittenTableScan.getLayout().isPresent()) { return false; } return Objects.equals(tableScan.getCurrentConstraint(), rewrittenTableScan.getCurrentConstraint()) && Objects.equals(tableScan.getEnforcedConstraint(), rewrittenTableScan.getEnforcedConstraint()); } }
@Override public PlanNode visitTableScan(TableScanNode node, RewriteContext<Set<Symbol>> context) { List<Symbol> newOutputs = node.getOutputSymbols().stream() .filter(context.get()::contains) .collect(toImmutableList()); Map<Symbol, ColumnHandle> newAssignments = newOutputs.stream() .collect(Collectors.toMap(Function.identity(), node.getAssignments()::get)); return new TableScanNode( node.getId(), node.getTable(), newOutputs, newAssignments, node.getLayout(), node.getCurrentConstraint(), node.getEnforcedConstraint()); }
private boolean arePlansSame(FilterNode filter, TableScanNode tableScan, PlanNode rewritten) { if (!(rewritten instanceof FilterNode)) { return false; } FilterNode rewrittenFilter = (FilterNode) rewritten; if (!Objects.equals(filter.getPredicate(), rewrittenFilter.getPredicate())) { return false; } if (!(rewrittenFilter.getSource() instanceof TableScanNode)) { return false; } TableScanNode rewrittenTableScan = (TableScanNode) rewrittenFilter.getSource(); if (!tableScan.getLayout().isPresent() && rewrittenTableScan.getLayout().isPresent()) { return false; } return Objects.equals(tableScan.getCurrentConstraint(), rewrittenTableScan.getCurrentConstraint()) && Objects.equals(tableScan.getEnforcedConstraint(), rewrittenTableScan.getEnforcedConstraint()); } }
@Override public PlanNode visitTableScan(TableScanNode node, RewriteContext<Set<Symbol>> context) { List<Symbol> newOutputs = node.getOutputSymbols().stream() .filter(context.get()::contains) .collect(toImmutableList()); Map<Symbol, ColumnHandle> newAssignments = newOutputs.stream() .collect(Collectors.toMap(Function.identity(), node.getAssignments()::get)); return new TableScanNode( node.getId(), node.getTable(), newOutputs, newAssignments, node.getLayout(), node.getCurrentConstraint(), node.getEnforcedConstraint()); }
@Override protected Optional<PlanNode> pushDownProjectOff(PlanNodeIdAllocator idAllocator, TableScanNode tableScanNode, Set<Symbol> referencedOutputs) { return Optional.of( new TableScanNode( tableScanNode.getId(), tableScanNode.getTable(), filteredCopy(tableScanNode.getOutputSymbols(), referencedOutputs::contains), filterKeys(tableScanNode.getAssignments(), referencedOutputs::contains), tableScanNode.getLayout(), tableScanNode.getCurrentConstraint(), tableScanNode.getEnforcedConstraint())); } }
@Override public PlanNode visitTableScan(TableScanNode node, RewriteContext<Void> context) { PartitioningHandle partitioning = node.getLayout() .map(layout -> metadata.getLayout(session, layout)) .flatMap(TableLayout::getTablePartitioning) .map(TablePartitioning::getPartitioningHandle) .orElse(SOURCE_DISTRIBUTION); if (partitioning.equals(fragmentPartitioningHandle)) { // do nothing if the current scan node's partitioning matches the fragment's return node; } TableLayoutHandle newTableLayoutHandle = metadata.getAlternativeLayoutHandle(session, node.getLayout().get(), fragmentPartitioningHandle); return new TableScanNode( node.getId(), node.getTable(), node.getOutputSymbols(), node.getAssignments(), Optional.of(newTableLayoutHandle), node.getCurrentConstraint(), node.getEnforcedConstraint()); } }
@Override public PlanNode visitTableScan(TableScanNode node, RewriteContext<Void> context) { PartitioningHandle partitioning = node.getLayout() .map(layout -> metadata.getLayout(session, layout)) .flatMap(TableLayout::getTablePartitioning) .map(TablePartitioning::getPartitioningHandle) .orElse(SOURCE_DISTRIBUTION); if (partitioning.equals(fragmentPartitioningHandle)) { // do nothing if the current scan node's partitioning matches the fragment's return node; } TableLayoutHandle newTableLayoutHandle = metadata.getAlternativeLayoutHandle(session, node.getLayout().get(), fragmentPartitioningHandle); return new TableScanNode( node.getId(), node.getTable(), node.getOutputSymbols(), node.getAssignments(), Optional.of(newTableLayoutHandle), node.getCurrentConstraint(), node.getEnforcedConstraint()); } }
@Override protected Optional<PlanNode> pushDownProjectOff(PlanNodeIdAllocator idAllocator, TableScanNode tableScanNode, Set<Symbol> referencedOutputs) { return Optional.of( new TableScanNode( tableScanNode.getId(), tableScanNode.getTable(), filteredCopy(tableScanNode.getOutputSymbols(), referencedOutputs::contains), filterKeys(tableScanNode.getAssignments(), referencedOutputs::contains), tableScanNode.getLayout(), tableScanNode.getCurrentConstraint(), tableScanNode.getEnforcedConstraint())); } }
TupleDomain<ColumnHandle> originalEnforcedConstraint = scan.getEnforcedConstraint();
TupleDomain<ColumnHandle> originalEnforcedConstraint = scan.getEnforcedConstraint();
.intersect(node.getEnforcedConstraint());
.intersect(node.getEnforcedConstraint());
.intersect(node.getEnforcedConstraint());
.intersect(node.getEnforcedConstraint());