Search in sources :

Example 1 with DeleteTarget

use of io.trino.sql.planner.plan.TableWriterNode.DeleteTarget in project trino by trinodb.

the class LocalExecutionPlanner method createTableFinisher.

private static TableFinisher createTableFinisher(Session session, TableFinishNode node, Metadata metadata) {
    WriterTarget target = node.getTarget();
    return (fragments, statistics, tableExecuteContext) -> {
        if (target instanceof CreateTarget) {
            return metadata.finishCreateTable(session, ((CreateTarget) target).getHandle(), fragments, statistics);
        } else if (target instanceof InsertTarget) {
            return metadata.finishInsert(session, ((InsertTarget) target).getHandle(), fragments, statistics);
        } else if (target instanceof TableWriterNode.RefreshMaterializedViewTarget) {
            TableWriterNode.RefreshMaterializedViewTarget refreshTarget = (TableWriterNode.RefreshMaterializedViewTarget) target;
            return metadata.finishRefreshMaterializedView(session, refreshTarget.getTableHandle(), refreshTarget.getInsertHandle(), fragments, statistics, refreshTarget.getSourceTableHandles());
        } else if (target instanceof DeleteTarget) {
            metadata.finishDelete(session, ((DeleteTarget) target).getHandleOrElseThrow(), fragments);
            return Optional.empty();
        } else if (target instanceof UpdateTarget) {
            metadata.finishUpdate(session, ((UpdateTarget) target).getHandleOrElseThrow(), fragments);
            return Optional.empty();
        } else if (target instanceof TableExecuteTarget) {
            TableExecuteHandle tableExecuteHandle = ((TableExecuteTarget) target).getExecuteHandle();
            metadata.finishTableExecute(session, tableExecuteHandle, fragments, tableExecuteContext.getSplitsInfo());
            return Optional.empty();
        } else {
            throw new AssertionError("Unhandled target type: " + target.getClass().getName());
        }
    };
}
Also used : RefreshMaterializedViewOperatorFactory(io.trino.operator.RefreshMaterializedViewOperator.RefreshMaterializedViewOperatorFactory) ArgumentComputationSupplier(io.trino.operator.window.pattern.ArgumentComputation.ArgumentComputationSupplier) SetSupplier(io.trino.operator.SetBuilderOperator.SetSupplier) RemoteSourceNode(io.trino.sql.planner.plan.RemoteSourceNode) ONE(io.trino.sql.tree.PatternRecognitionRelation.RowsPerMatch.ONE) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) PhysicalValueAccessor(io.trino.operator.window.pattern.PhysicalValueAccessor) SystemSessionProperties.isEnableCoordinatorDynamicFiltersDistribution(io.trino.SystemSessionProperties.isEnableCoordinatorDynamicFiltersDistribution) CursorProcessor(io.trino.operator.project.CursorProcessor) Map(java.util.Map) LOCAL(io.trino.sql.planner.plan.ExchangeNode.Scope.LOCAL) PartitionedOutputFactory(io.trino.operator.output.PartitionedOutputOperator.PartitionedOutputFactory) DistinctAccumulatorFactory(io.trino.operator.aggregation.DistinctAccumulatorFactory) TableScanNode(io.trino.sql.planner.plan.TableScanNode) ExplainAnalyzeNode(io.trino.sql.planner.plan.ExplainAnalyzeNode) SystemSessionProperties.isAdaptivePartialAggregationEnabled(io.trino.SystemSessionProperties.isAdaptivePartialAggregationEnabled) FIXED_BROADCAST_DISTRIBUTION(io.trino.sql.planner.SystemPartitioningHandle.FIXED_BROADCAST_DISTRIBUTION) Domain(io.trino.spi.predicate.Domain) SpatialPredicate(io.trino.operator.SpatialIndexBuilderOperator.SpatialPredicate) SemiJoinNode(io.trino.sql.planner.plan.SemiJoinNode) ST_CONTAINS(io.trino.util.SpatialJoinUtils.ST_CONTAINS) PageProjection(io.trino.operator.project.PageProjection) AggregationWindowFunctionSupplier(io.trino.operator.window.AggregationWindowFunctionSupplier) FIXED_ARBITRARY_DISTRIBUTION(io.trino.sql.planner.SystemPartitioningHandle.FIXED_ARBITRARY_DISTRIBUTION) DeleteTarget(io.trino.sql.planner.plan.TableWriterNode.DeleteTarget) TableExecuteTarget(io.trino.sql.planner.plan.TableWriterNode.TableExecuteTarget) SymbolReference(io.trino.sql.tree.SymbolReference) LocalMergeSourceOperatorFactory(io.trino.operator.exchange.LocalMergeSourceOperator.LocalMergeSourceOperatorFactory) TopNRankingNode(io.trino.sql.planner.plan.TopNRankingNode) ExpressionNodeInliner.replaceExpression(io.trino.sql.planner.ExpressionNodeInliner.replaceExpression) ValuesNode(io.trino.sql.planner.plan.ValuesNode) CLASSIFIER(io.trino.operator.window.pattern.PhysicalValuePointer.CLASSIFIER) LAST(io.trino.sql.tree.SkipTo.Position.LAST) Session(io.trino.Session) OrderedAccumulatorFactory(io.trino.operator.aggregation.OrderedAccumulatorFactory) SystemSessionProperties.isSpillEnabled(io.trino.SystemSessionProperties.isSpillEnabled) RegularPartitionerSupplier(io.trino.operator.window.RegularPartitionerSupplier) StageId(io.trino.execution.StageId) PageBuilder(io.trino.spi.PageBuilder) PagesSpatialIndexFactory(io.trino.operator.PagesSpatialIndexFactory) LimitNode(io.trino.sql.planner.plan.LimitNode) NestedLoopJoinOperatorFactory(io.trino.operator.join.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory) UpdateOperatorFactory(io.trino.operator.UpdateOperator.UpdateOperatorFactory) LookupSourceFactory(io.trino.operator.join.LookupSourceFactory) TableFinishOperatorFactory(io.trino.operator.TableFinishOperator.TableFinishOperatorFactory) Supplier(java.util.function.Supplier) LinkedHashMap(java.util.LinkedHashMap) VARCHAR(io.trino.spi.type.VarcharType.VARCHAR) Lists(com.google.common.collect.Lists) FunctionKind(io.trino.metadata.FunctionKind) SetBuilderOperatorFactory(io.trino.operator.SetBuilderOperator.SetBuilderOperatorFactory) RowNumberNode(io.trino.sql.planner.plan.RowNumberNode) SCALED_WRITER_DISTRIBUTION(io.trino.sql.planner.SystemPartitioningHandle.SCALED_WRITER_DISTRIBUTION) NodeRef(io.trino.sql.tree.NodeRef) JoinUtils.isBuildSideReplicated(io.trino.operator.join.JoinUtils.isBuildSideReplicated) AggregationNode(io.trino.sql.planner.plan.AggregationNode) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) WindowFunctionDefinition(io.trino.operator.WindowFunctionDefinition) DynamicFilterSourceOperatorFactory(io.trino.operator.DynamicFilterSourceOperator.DynamicFilterSourceOperatorFactory) JoinFilterFunctionFactory(io.trino.sql.gen.JoinFilterFunctionCompiler.JoinFilterFunctionFactory) EvaluationSupplier(io.trino.operator.window.pattern.LabelEvaluator.EvaluationSupplier) StageExecutionDescriptor(io.trino.operator.StageExecutionDescriptor) InsertTarget(io.trino.sql.planner.plan.TableWriterNode.InsertTarget) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) ROW_COUNT_CHANNEL(io.trino.operator.TableWriterOperator.ROW_COUNT_CHANNEL) AggregationMetadata(io.trino.operator.aggregation.AggregationMetadata) SortOrder(io.trino.spi.connector.SortOrder) OuterOperatorFactoryResult(io.trino.operator.join.JoinOperatorFactory.OuterOperatorFactoryResult) IndexBuildDriverFactoryProvider(io.trino.operator.index.IndexBuildDriverFactoryProvider) TableHandle(io.trino.metadata.TableHandle) GroupIdNode(io.trino.sql.planner.plan.GroupIdNode) MarkDistinctOperatorFactory(io.trino.operator.MarkDistinctOperator.MarkDistinctOperatorFactory) TableFinishNode(io.trino.sql.planner.plan.TableFinishNode) HOURS(java.util.concurrent.TimeUnit.HOURS) ROWS(io.trino.sql.tree.WindowFrame.Type.ROWS) TopNRankingOperator(io.trino.operator.TopNRankingOperator) IndexLookupSourceFactory(io.trino.operator.index.IndexLookupSourceFactory) IndexSourceNode(io.trino.sql.planner.plan.IndexSourceNode) DiscreteDomain.integers(com.google.common.collect.DiscreteDomain.integers) IntStream.range(java.util.stream.IntStream.range) JoinFilterFunctionCompiler(io.trino.sql.gen.JoinFilterFunctionCompiler) TableWriterNode(io.trino.sql.planner.plan.TableWriterNode) LocalPlannerAware(io.trino.operator.LocalPlannerAware) SystemSessionProperties.isLateMaterializationEnabled(io.trino.SystemSessionProperties.isLateMaterializationEnabled) LambdaArgumentDeclaration(io.trino.sql.tree.LambdaArgumentDeclaration) SortExpressionExtractor.extractSortExpression(io.trino.sql.planner.SortExpressionExtractor.extractSortExpression) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) HashMultimap(com.google.common.collect.HashMultimap) PagesSerdeFactory(io.trino.execution.buffer.PagesSerdeFactory) MatchAggregationInstantiator(io.trino.operator.window.pattern.MatchAggregation.MatchAggregationInstantiator) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Locale(java.util.Locale) SpatialJoinNode(io.trino.sql.planner.plan.SpatialJoinNode) LocalExchangeSinkOperatorFactory(io.trino.operator.exchange.LocalExchangeSinkOperator.LocalExchangeSinkOperatorFactory) DeleteNode(io.trino.sql.planner.plan.DeleteNode) LogicalIndexPointer(io.trino.sql.planner.rowpattern.LogicalIndexPointer) CreateTarget(io.trino.sql.planner.plan.TableWriterNode.CreateTarget) ASCENDING(io.trino.sql.tree.SortItem.Ordering.ASCENDING) ImmutableSetMultimap(com.google.common.collect.ImmutableSetMultimap) MarkDistinctNode(io.trino.sql.planner.plan.MarkDistinctNode) ImmutableSet(com.google.common.collect.ImmutableSet) ResolvedFunction(io.trino.metadata.ResolvedFunction) Collection(java.util.Collection) JoinOperatorFactory(io.trino.operator.join.JoinOperatorFactory) TableExecuteHandle(io.trino.metadata.TableExecuteHandle) PatternRecognitionNode(io.trino.sql.planner.plan.PatternRecognitionNode) Collectors(java.util.stream.Collectors) DynamicTupleFilterFactory(io.trino.operator.index.DynamicTupleFilterFactory) Objects(java.util.Objects) SafeCaches.buildNonEvictableCache(io.trino.collect.cache.SafeCaches.buildNonEvictableCache) COMPILER_ERROR(io.trino.spi.StandardErrorCode.COMPILER_ERROR) HashAggregationOperatorFactory(io.trino.operator.HashAggregationOperator.HashAggregationOperatorFactory) StatisticAggregationsDescriptor(io.trino.sql.planner.plan.StatisticAggregationsDescriptor) FieldSetFilteringRecordSet(io.trino.operator.index.FieldSetFilteringRecordSet) TableWriterOperatorFactory(io.trino.operator.TableWriterOperator.TableWriterOperatorFactory) BIGINT(io.trino.spi.type.BigintType.BIGINT) RIGHT(io.trino.sql.planner.plan.JoinNode.Type.RIGHT) NestedLoopJoinBridge(io.trino.operator.join.NestedLoopJoinBridge) Matcher(io.trino.operator.window.matcher.Matcher) COORDINATOR_DISTRIBUTION(io.trino.sql.planner.SystemPartitioningHandle.COORDINATOR_DISTRIBUTION) ExplainAnalyzeOperatorFactory(io.trino.operator.ExplainAnalyzeOperator.ExplainAnalyzeOperatorFactory) Range.closedOpen(com.google.common.collect.Range.closedOpen) ExchangeNode(io.trino.sql.planner.plan.ExchangeNode) PageSourceProvider(io.trino.split.PageSourceProvider) ExpressionUtils.combineConjuncts(io.trino.sql.ExpressionUtils.combineConjuncts) PlannerContext(io.trino.sql.PlannerContext) IntStream(java.util.stream.IntStream) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) UnionNode(io.trino.sql.planner.plan.UnionNode) TaskOutputFactory(io.trino.operator.output.TaskOutputOperator.TaskOutputFactory) INNER(io.trino.sql.planner.plan.JoinNode.Type.INNER) OrderingCompiler(io.trino.sql.gen.OrderingCompiler) LambdaExpression(io.trino.sql.tree.LambdaExpression) TopNOperator(io.trino.operator.TopNOperator) Measure(io.trino.sql.planner.plan.PatternRecognitionNode.Measure) RetryPolicy(io.trino.operator.RetryPolicy) PartitionerSupplier(io.trino.operator.window.PartitionerSupplier) SortNode(io.trino.sql.planner.plan.SortNode) OptionalInt(java.util.OptionalInt) Function(java.util.function.Function) ExpressionCompiler(io.trino.sql.gen.ExpressionCompiler) Inject(javax.inject.Inject) DistinctLimitOperatorFactory(io.trino.operator.DistinctLimitOperator.DistinctLimitOperatorFactory) LookupOuterOperatorFactory(io.trino.operator.join.LookupOuterOperator.LookupOuterOperatorFactory) OutputBuffer(io.trino.execution.buffer.OutputBuffer) ImmutableList(com.google.common.collect.ImmutableList) GROUPED_EXECUTION(io.trino.operator.PipelineExecutionStrategy.GROUPED_EXECUTION) SystemSessionProperties(io.trino.SystemSessionProperties) RefreshMaterializedViewNode(io.trino.sql.planner.plan.RefreshMaterializedViewNode) Frame(io.trino.sql.planner.plan.WindowNode.Frame) TableFinisher(io.trino.operator.TableFinishOperator.TableFinisher) TaskContext(io.trino.operator.TaskContext) ST_INTERSECTS(io.trino.util.SpatialJoinUtils.ST_INTERSECTS) PipelineExecutionStrategy(io.trino.operator.PipelineExecutionStrategy) DynamicFilterConfig(io.trino.execution.DynamicFilterConfig) IndexManager(io.trino.index.IndexManager) EnforceSingleRowOperator(io.trino.operator.EnforceSingleRowOperator) SimpleEntry(java.util.AbstractMap.SimpleEntry) CacheUtils.uncheckedCacheGet(io.trino.collect.cache.CacheUtils.uncheckedCacheGet) ProjectNode(io.trino.sql.planner.plan.ProjectNode) PagesIndex(io.trino.operator.PagesIndex) TableExecuteContextManager(io.trino.execution.TableExecuteContextManager) UNGROUPED_EXECUTION(io.trino.operator.PipelineExecutionStrategy.UNGROUPED_EXECUTION) ScanFilterAndProjectOperatorFactory(io.trino.operator.ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory) SingleStreamSpillerFactory(io.trino.spiller.SingleStreamSpillerFactory) FULL(io.trino.sql.planner.plan.JoinNode.Type.FULL) WriterTarget(io.trino.sql.planner.plan.TableWriterNode.WriterTarget) LogicalIndexNavigation(io.trino.operator.window.pattern.LogicalIndexNavigation) FilterAndProjectOperator(io.trino.operator.FilterAndProjectOperator) LocalExchangeSourceOperatorFactory(io.trino.operator.exchange.LocalExchangeSourceOperator.LocalExchangeSourceOperatorFactory) DistinctLimitNode(io.trino.sql.planner.plan.DistinctLimitNode) AccumulatorFactory(io.trino.operator.aggregation.AccumulatorFactory) FINAL(io.trino.sql.planner.plan.AggregationNode.Step.FINAL) SystemSessionProperties.getAdaptivePartialAggregationMinRows(io.trino.SystemSessionProperties.getAdaptivePartialAggregationMinRows) ExchangeManagerRegistry(io.trino.exchange.ExchangeManagerRegistry) MeasureComputationSupplier(io.trino.operator.window.pattern.MeasureComputation.MeasureComputationSupplier) WindowFunctionDefinition.window(io.trino.operator.WindowFunctionDefinition.window) Arrays(java.util.Arrays) SpatialJoinUtils.extractSupportedSpatialComparisons(io.trino.util.SpatialJoinUtils.extractSupportedSpatialComparisons) Ordering(io.trino.sql.tree.SortItem.Ordering) AggregationOperatorFactory(io.trino.operator.AggregationOperator.AggregationOperatorFactory) AggregationValuePointer(io.trino.sql.planner.rowpattern.AggregationValuePointer) LambdaDefinitionExpression(io.trino.sql.relational.LambdaDefinitionExpression) PlanNode(io.trino.sql.planner.plan.PlanNode) LEFT(io.trino.sql.planner.plan.JoinNode.Type.LEFT) HashBuilderOperatorFactory(io.trino.operator.join.HashBuilderOperator.HashBuilderOperatorFactory) Sets.difference(com.google.common.collect.Sets.difference) TableScanOperatorFactory(io.trino.operator.TableScanOperator.TableScanOperatorFactory) PhysicalValuePointer(io.trino.operator.window.pattern.PhysicalValuePointer) DynamicFilters(io.trino.sql.DynamicFilters) FunctionType(io.trino.type.FunctionType) TableDeleteOperatorFactory(io.trino.operator.TableDeleteOperator.TableDeleteOperatorFactory) ExpressionExtractor.extractExpressions(io.trino.sql.planner.ExpressionExtractor.extractExpressions) OutputNode(io.trino.sql.planner.plan.OutputNode) SystemSessionProperties.getAdaptivePartialAggregationUniqueRowsRatioThreshold(io.trino.SystemSessionProperties.getAdaptivePartialAggregationUniqueRowsRatioThreshold) FrameInfo(io.trino.operator.window.FrameInfo) UnnestOperatorFactory(io.trino.operator.unnest.UnnestOperator.UnnestOperatorFactory) FRAGMENT_CHANNEL(io.trino.operator.TableWriterOperator.FRAGMENT_CHANNEL) IndexSourceOperator(io.trino.operator.index.IndexSourceOperator) StreamingAggregationOperator(io.trino.operator.StreamingAggregationOperator) PageSinkManager(io.trino.split.PageSinkManager) StatisticsWriterNode(io.trino.sql.planner.plan.StatisticsWriterNode) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Assignments(io.trino.sql.planner.plan.Assignments) Set(java.util.Set) TypeUtils.writeNativeValue(io.trino.spi.type.TypeUtils.writeNativeValue) HashArraySizeSupplier.incrementalLoadFactorHashArraySizeSupplier(io.trino.operator.HashArraySizeSupplier.incrementalLoadFactorHashArraySizeSupplier) IndexJoinLookupStats(io.trino.operator.index.IndexJoinLookupStats) TaskManagerConfig(io.trino.execution.TaskManagerConfig) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) LambdaBytecodeGenerator.compileLambdaProvider(io.trino.sql.gen.LambdaBytecodeGenerator.compileLambdaProvider) RecordSet(io.trino.spi.connector.RecordSet) SpillerFactory(io.trino.spiller.SpillerFactory) SystemSessionProperties.getFilterAndProjectMinOutputPageSize(io.trino.SystemSessionProperties.getFilterAndProjectMinOutputPageSize) ST_WITHIN(io.trino.util.SpatialJoinUtils.ST_WITHIN) ExplainAnalyzeContext(io.trino.execution.ExplainAnalyzeContext) MoreObjects.toStringHelper(com.google.common.base.MoreObjects.toStringHelper) ValuesOperatorFactory(io.trino.operator.ValuesOperator.ValuesOperatorFactory) TableExecuteNode(io.trino.sql.planner.plan.TableExecuteNode) Iterables(com.google.common.collect.Iterables) SqlToRowExpressionTranslator(io.trino.sql.relational.SqlToRowExpressionTranslator) Collectors.partitioningBy(java.util.stream.Collectors.partitioningBy) ContiguousSet(com.google.common.collect.ContiguousSet) OrderByOperatorFactory(io.trino.operator.OrderByOperator.OrderByOperatorFactory) NullableValue(io.trino.spi.predicate.NullableValue) Page(io.trino.spi.Page) IndexJoinOptimizer(io.trino.sql.planner.optimizations.IndexJoinOptimizer) JoinCompiler(io.trino.sql.gen.JoinCompiler) IrRowPatternToProgramRewriter(io.trino.operator.window.matcher.IrRowPatternToProgramRewriter) SetEvaluatorSupplier(io.trino.operator.window.pattern.SetEvaluator.SetEvaluatorSupplier) JoinBridgeManager(io.trino.operator.join.JoinBridgeManager) DynamicFilterId(io.trino.sql.planner.plan.DynamicFilterId) ArrayList(java.util.ArrayList) LocalExchangeFactory(io.trino.operator.exchange.LocalExchange.LocalExchangeFactory) UpdateTarget(io.trino.sql.planner.plan.TableWriterNode.UpdateTarget) STATS_START_CHANNEL(io.trino.operator.TableWriterOperator.STATS_START_CHANNEL) ST_DISTANCE(io.trino.util.SpatialJoinUtils.ST_DISTANCE) NestedLoopJoinPagesSupplier(io.trino.operator.join.NestedLoopJoinPagesSupplier) PageChannelSelector(io.trino.operator.exchange.PageChannelSelector) ColumnHandle(io.trino.spi.connector.ColumnHandle) StatisticsWriterOperatorFactory(io.trino.operator.StatisticsWriterOperator.StatisticsWriterOperatorFactory) PartitioningSpillerFactory.unsupportedPartitioningSpillerFactory(io.trino.spiller.PartitioningSpillerFactory.unsupportedPartitioningSpillerFactory) SourceOperatorFactory(io.trino.operator.SourceOperatorFactory) BlockTypeOperators(io.trino.type.BlockTypeOperators) MatchAggregationPointer(io.trino.operator.window.pattern.MatchAggregationPointer) IrLabel(io.trino.sql.planner.rowpattern.ir.IrLabel) ConnectorSession(io.trino.spi.connector.ConnectorSession) LESS_THAN(io.trino.sql.tree.ComparisonExpression.Operator.LESS_THAN) DevNullOperatorFactory(io.trino.operator.DevNullOperator.DevNullOperatorFactory) UnnestNode(io.trino.sql.planner.plan.UnnestNode) WorkProcessorPipelineSourceOperator.toOperatorFactories(io.trino.operator.WorkProcessorPipelineSourceOperator.toOperatorFactories) NestedLoopBuildOperatorFactory(io.trino.operator.join.NestedLoopBuildOperator.NestedLoopBuildOperatorFactory) MoreFutures.addSuccessCallback(io.airlift.concurrent.MoreFutures.addSuccessCallback) SampleNode(io.trino.sql.planner.plan.SampleNode) PartitionedLookupSourceFactory(io.trino.operator.join.PartitionedLookupSourceFactory) SpatialJoinOperatorFactory(io.trino.operator.SpatialJoinOperator.SpatialJoinOperatorFactory) MappedRecordSet(io.trino.split.MappedRecordSet) SystemSessionProperties.getTaskWriterCount(io.trino.SystemSessionProperties.getTaskWriterCount) DriverFactory(io.trino.operator.DriverFactory) MergeOperatorFactory(io.trino.operator.MergeOperator.MergeOperatorFactory) RowNumberOperator(io.trino.operator.RowNumberOperator) Aggregation(io.trino.sql.planner.plan.AggregationNode.Aggregation) Step(io.trino.sql.planner.plan.AggregationNode.Step) CURRENT_ROW(io.trino.sql.tree.FrameBound.Type.CURRENT_ROW) DynamicFilters.extractDynamicFilters(io.trino.sql.DynamicFilters.extractDynamicFilters) PartialAggregationController(io.trino.operator.aggregation.partial.PartialAggregationController) WindowFunctionSupplier(io.trino.operator.window.WindowFunctionSupplier) FilterNode(io.trino.sql.planner.plan.FilterNode) TableDeleteNode(io.trino.sql.planner.plan.TableDeleteNode) Iterables.concat(com.google.common.collect.Iterables.concat) SINGLE_DISTRIBUTION(io.trino.sql.planner.SystemPartitioningHandle.SINGLE_DISTRIBUTION) JoinNode(io.trino.sql.planner.plan.JoinNode) AssignUniqueId(io.trino.sql.planner.plan.AssignUniqueId) FunctionCall(io.trino.sql.tree.FunctionCall) RowType(io.trino.spi.type.RowType) ImmutableMap(com.google.common.collect.ImmutableMap) PatternRecognitionPartitionerSupplier(io.trino.operator.window.PatternRecognitionPartitionerSupplier) Collections.nCopies(java.util.Collections.nCopies) EnforceSingleRowNode(io.trino.sql.planner.plan.EnforceSingleRowNode) PageFunctionCompiler(io.trino.sql.gen.PageFunctionCompiler) IndexJoinNode(io.trino.sql.planner.plan.IndexJoinNode) TrinoException(io.trino.spi.TrinoException) OutputFactory(io.trino.operator.OutputFactory) SystemSessionProperties.getTaskConcurrency(io.trino.SystemSessionProperties.getTaskConcurrency) TaskId(io.trino.execution.TaskId) ComparisonExpression(io.trino.sql.tree.ComparisonExpression) SystemSessionProperties.getAggregationOperatorUnspillMemoryLimit(io.trino.SystemSessionProperties.getAggregationOperatorUnspillMemoryLimit) Preconditions.checkState(com.google.common.base.Preconditions.checkState) LESS_THAN_OR_EQUAL(io.trino.sql.tree.ComparisonExpression.Operator.LESS_THAN_OR_EQUAL) DirectExchangeClientSupplier(io.trino.operator.DirectExchangeClientSupplier) SystemSessionProperties.isExchangeCompressionEnabled(io.trino.SystemSessionProperties.isExchangeCompressionEnabled) DataSize(io.airlift.units.DataSize) AggregatorFactory(io.trino.operator.aggregation.AggregatorFactory) List(java.util.List) DynamicFilter(io.trino.spi.connector.DynamicFilter) Optional(java.util.Optional) Expression(io.trino.sql.tree.Expression) CacheBuilder(com.google.common.cache.CacheBuilder) WindowNode(io.trino.sql.planner.plan.WindowNode) ConnectorIndex(io.trino.spi.connector.ConnectorIndex) DynamicFilterSourceOperator(io.trino.operator.DynamicFilterSourceOperator) DESCENDING(io.trino.sql.tree.SortItem.Ordering.DESCENDING) OperatorFactories(io.trino.operator.OperatorFactories) Functions.forMap(com.google.common.base.Functions.forMap) Logger(io.airlift.log.Logger) SystemSessionProperties.isEnableLargeDynamicFilters(io.trino.SystemSessionProperties.isEnableLargeDynamicFilters) PositionsAppenderFactory(io.trino.operator.output.PositionsAppenderFactory) Type(io.trino.spi.type.Type) HashMap(java.util.HashMap) Multimap(com.google.common.collect.Multimap) SystemSessionProperties.getFilterAndProjectMinOutputPageRowCount(io.trino.SystemSessionProperties.getFilterAndProjectMinOutputPageRowCount) ImmutableBiMap(com.google.common.collect.ImmutableBiMap) WindowOperatorFactory(io.trino.operator.WindowOperator.WindowOperatorFactory) Verify.verify(com.google.common.base.Verify.verify) Objects.requireNonNull(java.util.Objects.requireNonNull) GroupIdOperator(io.trino.operator.GroupIdOperator) PageProcessor(io.trino.operator.project.PageProcessor) ExchangeOperatorFactory(io.trino.operator.ExchangeOperator.ExchangeOperatorFactory) AssignUniqueIdOperator(io.trino.operator.AssignUniqueIdOperator) NonEvictableCache(io.trino.collect.cache.NonEvictableCache) ExpressionAndValuePointers(io.trino.sql.planner.rowpattern.LogicalIndexExtractor.ExpressionAndValuePointers) OperatorFactory(io.trino.operator.OperatorFactory) VerifyException(com.google.common.base.VerifyException) PARTIAL(io.trino.sql.planner.plan.AggregationNode.Step.PARTIAL) FunctionId(io.trino.metadata.FunctionId) HashSemiJoinOperator(io.trino.operator.HashSemiJoinOperator) PartitionFunction(io.trino.operator.PartitionFunction) PlanVisitor(io.trino.sql.planner.plan.PlanVisitor) TopNNode(io.trino.sql.planner.plan.TopNNode) ScalarValuePointer(io.trino.sql.planner.rowpattern.ScalarValuePointer) LimitOperatorFactory(io.trino.operator.LimitOperator.LimitOperatorFactory) SingleRowBlock(io.trino.spi.block.SingleRowBlock) TRUE_LITERAL(io.trino.sql.tree.BooleanLiteral.TRUE_LITERAL) Ints(com.google.common.primitives.Ints) SetMultimap(com.google.common.collect.SetMultimap) AccumulatorCompiler.generateAccumulatorFactory(io.trino.operator.aggregation.AccumulatorCompiler.generateAccumulatorFactory) UpdateNode(io.trino.sql.planner.plan.UpdateNode) MATCH_NUMBER(io.trino.operator.window.pattern.PhysicalValuePointer.MATCH_NUMBER) DeleteOperatorFactory(io.trino.operator.DeleteOperator.DeleteOperatorFactory) WorkProcessorPipelineSourceOperator(io.trino.operator.WorkProcessorPipelineSourceOperator) PartitioningSpillerFactory(io.trino.spiller.PartitioningSpillerFactory) RowExpression(io.trino.sql.relational.RowExpression) Program(io.trino.operator.window.matcher.Program) BoundSignature(io.trino.metadata.BoundSignature) SpatialIndexBuilderOperatorFactory(io.trino.operator.SpatialIndexBuilderOperator.SpatialIndexBuilderOperatorFactory) ValuePointer(io.trino.sql.planner.rowpattern.ValuePointer) Metadata(io.trino.metadata.Metadata) TypeUtils.readNativeValue(io.trino.spi.type.TypeUtils.readNativeValue) SpatialJoinUtils.extractSupportedSpatialFunctions(io.trino.util.SpatialJoinUtils.extractSupportedSpatialFunctions) CreateTarget(io.trino.sql.planner.plan.TableWriterNode.CreateTarget) UpdateTarget(io.trino.sql.planner.plan.TableWriterNode.UpdateTarget) TableExecuteHandle(io.trino.metadata.TableExecuteHandle) TableExecuteTarget(io.trino.sql.planner.plan.TableWriterNode.TableExecuteTarget) DeleteTarget(io.trino.sql.planner.plan.TableWriterNode.DeleteTarget) WriterTarget(io.trino.sql.planner.plan.TableWriterNode.WriterTarget) InsertTarget(io.trino.sql.planner.plan.TableWriterNode.InsertTarget) TableWriterNode(io.trino.sql.planner.plan.TableWriterNode)

Example 2 with DeleteTarget

use of io.trino.sql.planner.plan.TableWriterNode.DeleteTarget in project trino by trinodb.

the class QueryPlanner method plan.

public DeleteNode plan(Delete node) {
    Table table = node.getTable();
    TableHandle handle = analysis.getTableHandle(table);
    // create table scan
    RelationPlan relationPlan = new RelationPlanner(analysis, symbolAllocator, idAllocator, lambdaDeclarationToSymbolMap, plannerContext, outerContext, session, recursiveSubqueries).process(table, null);
    PlanBuilder builder = newPlanBuilder(relationPlan, analysis, lambdaDeclarationToSymbolMap);
    if (node.getWhere().isPresent()) {
        builder = filter(builder, node.getWhere().get(), node);
    }
    // create delete node
    Symbol rowId = builder.translate(analysis.getRowIdField(table));
    List<Symbol> outputs = ImmutableList.of(symbolAllocator.newSymbol("partialrows", BIGINT), symbolAllocator.newSymbol("fragment", VARBINARY));
    return new DeleteNode(idAllocator.getNextId(), builder.getRoot(), new DeleteTarget(Optional.empty(), plannerContext.getMetadata().getTableMetadata(session, handle).getTable()), rowId, outputs);
}
Also used : DeleteNode(io.trino.sql.planner.plan.DeleteNode) Table(io.trino.sql.tree.Table) TableHandle(io.trino.metadata.TableHandle) DeleteTarget(io.trino.sql.planner.plan.TableWriterNode.DeleteTarget) PlanBuilder.newPlanBuilder(io.trino.sql.planner.PlanBuilder.newPlanBuilder)

Aggregations

Functions.forMap (com.google.common.base.Functions.forMap)1 MoreObjects.toStringHelper (com.google.common.base.MoreObjects.toStringHelper)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 Verify.verify (com.google.common.base.Verify.verify)1 VerifyException (com.google.common.base.VerifyException)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 ContiguousSet (com.google.common.collect.ContiguousSet)1 DiscreteDomain.integers (com.google.common.collect.DiscreteDomain.integers)1 HashMultimap (com.google.common.collect.HashMultimap)1 ImmutableBiMap (com.google.common.collect.ImmutableBiMap)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableMap.toImmutableMap (com.google.common.collect.ImmutableMap.toImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)1 ImmutableSetMultimap (com.google.common.collect.ImmutableSetMultimap)1 Iterables (com.google.common.collect.Iterables)1 Iterables.concat (com.google.common.collect.Iterables.concat)1