@Override public Void visitTableScan(TableScanNode node, Void context) { TableHandle tableHandle = node.getTable(); Set<Column> columns = new HashSet<>(); for (ColumnHandle columnHandle : node.getAssignments().values()) { columns.add(createColumn(metadata.getColumnMetadata(session, tableHandle, columnHandle))); } inputs.add(createInput(metadata.getTableMetadata(session, tableHandle), node.getLayout(), columns)); return null; }
@Override public Void visitTableScan(TableScanNode node, Void context) { TableHandle tableHandle = node.getTable(); Set<Column> columns = new HashSet<>(); for (ColumnHandle columnHandle : node.getAssignments().values()) { columns.add(createColumn(metadata.getColumnMetadata(session, tableHandle, columnHandle))); } inputs.add(createInput(metadata.getTableMetadata(session, tableHandle), node.getLayout(), columns)); return null; }
@Override public Map<PlanNodeId, SplitSource> visitTableScan(TableScanNode node, Void context) { // get dataSource for table SplitSource splitSource = splitManager.getSplits( session, node.getLayout().get(), stageExecutionDescriptor.isScanGroupedExecution(node.getId()) ? GROUPED_SCHEDULING : UNGROUPED_SCHEDULING); splitSources.add(splitSource); return ImmutableMap.of(node.getId(), splitSource); }
@Override public Map<PlanNodeId, SplitSource> visitTableScan(TableScanNode node, Void context) { // get dataSource for table SplitSource splitSource = splitManager.getSplits( session, node.getLayout().get(), stageExecutionStrategy.isGroupedExecution(node.getId()) ? GROUPED_SCHEDULING : UNGROUPED_SCHEDULING); splitSources.add(splitSource); return ImmutableMap.of(node.getId(), splitSource); }
private boolean hasTableLayout(TableScanNode tableScanNode) { return !hasTableLayout.isPresent() || hasTableLayout.get() == tableScanNode.getLayout().isPresent(); }
private boolean hasTableLayout(TableScanNode tableScanNode) { return !hasTableLayout.isPresent() || hasTableLayout.get() == tableScanNode.getLayout().isPresent(); }
@Override public StreamProperties visitTableScan(TableScanNode node, List<StreamProperties> inputProperties) { checkArgument(node.getLayout().isPresent(), "table layout has not yet been chosen"); TableLayout layout = metadata.getLayout(session, node.getLayout().get()); Map<ColumnHandle, Symbol> assignments = ImmutableBiMap.copyOf(node.getAssignments()).inverse(); // Globally constant assignments Set<ColumnHandle> constants = new HashSet<>(); extractFixedValues(node.getCurrentConstraint()).orElse(ImmutableMap.of()) .entrySet().stream() .filter(entry -> !entry.getValue().isNull()) // TODO consider allowing nulls .forEach(entry -> constants.add(entry.getKey())); Optional<Set<Symbol>> streamPartitionSymbols = layout.getStreamPartitioningColumns() .flatMap(columns -> getNonConstantSymbols(columns, assignments, constants)); // if we are partitioned on empty set, we must say multiple of unknown partitioning, because // the connector does not guarantee a single split in this case (since it might not understand // that the value is a constant). if (streamPartitionSymbols.isPresent() && streamPartitionSymbols.get().isEmpty()) { return new StreamProperties(MULTIPLE, Optional.empty(), false); } return new StreamProperties(MULTIPLE, streamPartitionSymbols, false); }
@Override public PlanNode visitTableScan(TableScanNode node, RewriteContext<FragmentProperties> context) { PartitioningHandle partitioning = node.getLayout() .map(layout -> metadata.getLayout(session, layout)) .flatMap(TableLayout::getTablePartitioning) .map(TablePartitioning::getPartitioningHandle) .orElse(SOURCE_DISTRIBUTION); context.get().addSourceDistribution(node.getId(), partitioning, metadata, session); return context.defaultRewrite(node, context.get()); }
@Override public PlanNode visitTableScan(TableScanNode node, RewriteContext<FragmentProperties> context) { PartitioningHandle partitioning = node.getLayout() .map(layout -> metadata.getLayout(session, layout)) .flatMap(TableLayout::getTablePartitioning) .map(TablePartitioning::getPartitioningHandle) .orElse(SOURCE_DISTRIBUTION); context.get().addSourceDistribution(node.getId(), partitioning, metadata, session); return context.defaultRewrite(node, context.get()); }
@Override public GroupedExecutionProperties visitTableScan(TableScanNode node, Void context) { Optional<TablePartitioning> tablePartitioning = metadata.getLayout(session, node.getLayout().get()).getTablePartitioning(); if (!tablePartitioning.isPresent()) { return GroupedExecutionProperties.notCapable(); } List<ConnectorPartitionHandle> partitionHandles = nodePartitioningManager.listPartitionHandles(session, tablePartitioning.get().getPartitioningHandle()); if (ImmutableList.of(NOT_PARTITIONED).equals(partitionHandles)) { return new GroupedExecutionProperties(false, false, ImmutableList.of()); } else { return new GroupedExecutionProperties(true, false, ImmutableList.of(node.getId())); } }
@Override public GroupedExecutionProperties visitTableScan(TableScanNode node, Void context) { Optional<TablePartitioning> tablePartitioning = metadata.getLayout(session, node.getLayout().get()).getTablePartitioning(); if (!tablePartitioning.isPresent()) { return GroupedExecutionProperties.notCapable(); } List<ConnectorPartitionHandle> partitionHandles = nodePartitioningManager.listPartitionHandles(session, tablePartitioning.get().getPartitioningHandle()); if (ImmutableList.of(NOT_PARTITIONED).equals(partitionHandles)) { return new GroupedExecutionProperties(false, false, ImmutableList.of()); } else { return new GroupedExecutionProperties(true, false, ImmutableList.of(node.getId())); } }
@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 public PlanNode visitTableFinish(TableFinishNode node, RewriteContext<Void> context) { Optional<DeleteNode> delete = findNode(node.getSource(), DeleteNode.class); if (!delete.isPresent()) { return context.defaultRewrite(node); } Optional<TableScanNode> tableScan = findNode(delete.get().getSource(), TableScanNode.class); if (!tableScan.isPresent()) { return context.defaultRewrite(node); } TableScanNode tableScanNode = tableScan.get(); if (!metadata.supportsMetadataDelete(session, tableScanNode.getTable(), tableScanNode.getLayout().get())) { return context.defaultRewrite(node); } return new MetadataDeleteNode(idAllocator.getNextId(), delete.get().getTarget(), Iterables.getOnlyElement(node.getOutputSymbols()), tableScanNode.getLayout().get()); }
@Override public PlanNode visitTableFinish(TableFinishNode node, RewriteContext<Void> context) { Optional<DeleteNode> delete = findNode(node.getSource(), DeleteNode.class); if (!delete.isPresent()) { return context.defaultRewrite(node); } Optional<TableScanNode> tableScan = findNode(delete.get().getSource(), TableScanNode.class); if (!tableScan.isPresent()) { return context.defaultRewrite(node); } TableScanNode tableScanNode = tableScan.get(); if (!metadata.supportsMetadataDelete(session, tableScanNode.getTable(), tableScanNode.getLayout().get())) { return context.defaultRewrite(node); } return new MetadataDeleteNode(idAllocator.getNextId(), delete.get().getTarget(), Iterables.getOnlyElement(node.getOutputSymbols()), tableScanNode.getLayout().get()); }
@Override public Result apply(TableScanNode tableScanNode, Captures captures, Context context) { if (tableScanNode.getLayout().isPresent()) { return Result.empty(); } return Result.ofPlanNode(planTableScan(tableScanNode, TRUE_LITERAL, context.getSession(), context.getSymbolAllocator().getTypes(), context.getIdAllocator(), metadata, parser, domainTranslator)); } }
@Override public Result apply(TableScanNode tableScanNode, Captures captures, Context context) { if (tableScanNode.getLayout().isPresent()) { return Result.empty(); } return Result.ofPlanNode(planTableScan(tableScanNode, TRUE_LITERAL, context.getSession(), context.getSymbolAllocator().getTypes(), context.getIdAllocator(), metadata, parser, domainTranslator)); } }
@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 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())); } }