Search in sources :

Example 16 with Metadata

use of io.trino.metadata.Metadata in project trino by trinodb.

the class DistinctLimitMatcher method detailMatches.

@Override
public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases) {
    checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
    DistinctLimitNode distinctLimitNode = (DistinctLimitNode) node;
    if (distinctLimitNode.getLimit() != limit) {
        return NO_MATCH;
    }
    if (!distinctLimitNode.getHashSymbol().equals(hashSymbol.map(alias -> alias.toSymbol(symbolAliases)))) {
        return NO_MATCH;
    }
    return new MatchResult(ImmutableSet.copyOf(distinctLimitNode.getDistinctSymbols()).equals(distinctSymbols.stream().map(alias -> alias.toSymbol(symbolAliases)).collect(toImmutableSet())));
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) StatsProvider(io.trino.cost.StatsProvider) PlanNode(io.trino.sql.planner.plan.PlanNode) Preconditions.checkState(com.google.common.base.Preconditions.checkState) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Objects.requireNonNull(java.util.Objects.requireNonNull) DistinctLimitNode(io.trino.sql.planner.plan.DistinctLimitNode) Metadata(io.trino.metadata.Metadata) Optional(java.util.Optional) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) NO_MATCH(io.trino.sql.planner.assertions.MatchResult.NO_MATCH) Session(io.trino.Session) MoreObjects.toStringHelper(com.google.common.base.MoreObjects.toStringHelper) DistinctLimitNode(io.trino.sql.planner.plan.DistinctLimitNode)

Example 17 with Metadata

use of io.trino.metadata.Metadata in project trino by trinodb.

the class GrantRolesTask method execute.

@Override
public ListenableFuture<Void> execute(GrantRoles statement, QueryStateMachine stateMachine, List<Expression> parameters, WarningCollector warningCollector) {
    Session session = stateMachine.getSession();
    Set<String> roles = statement.getRoles().stream().map(role -> role.getValue().toLowerCase(Locale.ENGLISH)).collect(toImmutableSet());
    Set<TrinoPrincipal> grantees = statement.getGrantees().stream().map(MetadataUtil::createPrincipal).collect(toImmutableSet());
    boolean adminOption = statement.isAdminOption();
    Optional<TrinoPrincipal> grantor = statement.getGrantor().map(specification -> createPrincipal(session, specification));
    Optional<String> catalog = processRoleCommandCatalog(metadata, session, statement, statement.getCatalog().map(Identifier::getValue));
    Set<String> specifiedRoles = new LinkedHashSet<>();
    specifiedRoles.addAll(roles);
    grantees.stream().filter(principal -> principal.getType() == ROLE).map(TrinoPrincipal::getName).forEach(specifiedRoles::add);
    if (grantor.isPresent() && grantor.get().getType() == ROLE) {
        specifiedRoles.add(grantor.get().getName());
    }
    for (String role : specifiedRoles) {
        checkRoleExists(session, statement, metadata, role, catalog);
    }
    accessControl.checkCanGrantRoles(session.toSecurityContext(), roles, grantees, adminOption, grantor, catalog);
    metadata.grantRoles(session, roles, grantees, adminOption, grantor, catalog);
    return immediateVoidFuture();
}
Also used : Futures.immediateVoidFuture(com.google.common.util.concurrent.Futures.immediateVoidFuture) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) MetadataUtil.checkRoleExists(io.trino.metadata.MetadataUtil.checkRoleExists) MetadataUtil(io.trino.metadata.MetadataUtil) Set(java.util.Set) ROLE(io.trino.spi.security.PrincipalType.ROLE) GrantRoles(io.trino.sql.tree.GrantRoles) Inject(javax.inject.Inject) List(java.util.List) AccessControl(io.trino.security.AccessControl) TrinoPrincipal(io.trino.spi.security.TrinoPrincipal) MetadataUtil.createPrincipal(io.trino.metadata.MetadataUtil.createPrincipal) Locale(java.util.Locale) Objects.requireNonNull(java.util.Objects.requireNonNull) WarningCollector(io.trino.execution.warnings.WarningCollector) Metadata(io.trino.metadata.Metadata) Optional(java.util.Optional) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) Expression(io.trino.sql.tree.Expression) MetadataUtil.processRoleCommandCatalog(io.trino.metadata.MetadataUtil.processRoleCommandCatalog) Identifier(io.trino.sql.tree.Identifier) LinkedHashSet(java.util.LinkedHashSet) Session(io.trino.Session) LinkedHashSet(java.util.LinkedHashSet) TrinoPrincipal(io.trino.spi.security.TrinoPrincipal) Session(io.trino.Session)

Example 18 with Metadata

use of io.trino.metadata.Metadata in project trino by trinodb.

the class SimpleFilterProjectSemiJoinStatsRule method extractSemiJoinOutputFilter.

private Optional<SemiJoinOutputFilter> extractSemiJoinOutputFilter(Expression predicate, Symbol semiJoinOutput) {
    List<Expression> conjuncts = extractConjuncts(predicate);
    List<Expression> semiJoinOutputReferences = conjuncts.stream().filter(conjunct -> isSemiJoinOutputReference(conjunct, semiJoinOutput)).collect(toImmutableList());
    if (semiJoinOutputReferences.size() != 1) {
        return Optional.empty();
    }
    Expression semiJoinOutputReference = Iterables.getOnlyElement(semiJoinOutputReferences);
    Expression remainingPredicate = combineConjuncts(metadata, conjuncts.stream().filter(conjunct -> conjunct != semiJoinOutputReference).collect(toImmutableList()));
    boolean negated = semiJoinOutputReference instanceof NotExpression;
    return Optional.of(new SemiJoinOutputFilter(negated, remainingPredicate));
}
Also used : Symbol(io.trino.sql.planner.Symbol) Iterables(com.google.common.collect.Iterables) Lookup(io.trino.sql.planner.iterative.Lookup) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Patterns.filter(io.trino.sql.planner.plan.Patterns.filter) SemiJoinNode(io.trino.sql.planner.plan.SemiJoinNode) UNKNOWN_FILTER_COEFFICIENT(io.trino.cost.FilterStatsCalculator.UNKNOWN_FILTER_COEFFICIENT) FilterNode(io.trino.sql.planner.plan.FilterNode) PlanNode(io.trino.sql.planner.plan.PlanNode) SemiJoinStatsCalculator.computeSemiJoin(io.trino.cost.SemiJoinStatsCalculator.computeSemiJoin) List(java.util.List) Pattern(io.trino.matching.Pattern) SymbolReference(io.trino.sql.tree.SymbolReference) SemiJoinStatsCalculator.computeAntiJoin(io.trino.cost.SemiJoinStatsCalculator.computeAntiJoin) NotExpression(io.trino.sql.tree.NotExpression) Objects.requireNonNull(java.util.Objects.requireNonNull) Metadata(io.trino.metadata.Metadata) TypeProvider(io.trino.sql.planner.TypeProvider) Optional(java.util.Optional) Expression(io.trino.sql.tree.Expression) ExpressionUtils.extractConjuncts(io.trino.sql.ExpressionUtils.extractConjuncts) ExpressionUtils.combineConjuncts(io.trino.sql.ExpressionUtils.combineConjuncts) ProjectNode(io.trino.sql.planner.plan.ProjectNode) Session(io.trino.Session) NotExpression(io.trino.sql.tree.NotExpression) Expression(io.trino.sql.tree.Expression) NotExpression(io.trino.sql.tree.NotExpression)

Example 19 with Metadata

use of io.trino.metadata.Metadata 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 20 with Metadata

use of io.trino.metadata.Metadata in project trino by trinodb.

the class LogicalPlanner method getInsertPlan.

private RelationPlan getInsertPlan(Analysis analysis, Table table, Query query, TableHandle tableHandle, List<ColumnHandle> insertColumns, Optional<TableLayout> newTableLayout, Optional<WriterTarget> materializedViewRefreshWriterTarget) {
    TableMetadata tableMetadata = metadata.getTableMetadata(session, tableHandle);
    Map<NodeRef<LambdaArgumentDeclaration>, Symbol> lambdaDeclarationToSymbolMap = buildLambdaDeclarationToSymbolMap(analysis, symbolAllocator);
    RelationPlanner planner = new RelationPlanner(analysis, symbolAllocator, idAllocator, lambdaDeclarationToSymbolMap, plannerContext, Optional.empty(), session, ImmutableMap.of());
    RelationPlan plan = planner.process(query, null);
    ImmutableList.Builder<Symbol> builder = ImmutableList.builder();
    for (int i = 0; i < plan.getFieldMappings().size(); i++) {
        if (!plan.getDescriptor().getFieldByIndex(i).isHidden()) {
            builder.add(plan.getFieldMappings().get(i));
        }
    }
    List<Symbol> visibleFieldMappings = builder.build();
    Map<String, ColumnHandle> columns = metadata.getColumnHandles(session, tableHandle);
    Assignments.Builder assignments = Assignments.builder();
    boolean supportsMissingColumnsOnInsert = metadata.supportsMissingColumnsOnInsert(session, tableHandle);
    ImmutableList.Builder<ColumnMetadata> insertedColumnsBuilder = ImmutableList.builder();
    for (ColumnMetadata column : tableMetadata.getColumns()) {
        if (column.isHidden()) {
            continue;
        }
        Symbol output = symbolAllocator.newSymbol(column.getName(), column.getType());
        int index = insertColumns.indexOf(columns.get(column.getName()));
        if (index < 0) {
            if (supportsMissingColumnsOnInsert) {
                continue;
            }
            Expression cast = new Cast(new NullLiteral(), toSqlType(column.getType()));
            assignments.put(output, cast);
            insertedColumnsBuilder.add(column);
        } else {
            Symbol input = visibleFieldMappings.get(index);
            Type tableType = column.getType();
            Type queryType = symbolAllocator.getTypes().get(input);
            if (queryType.equals(tableType) || typeCoercion.isTypeOnlyCoercion(queryType, tableType)) {
                assignments.put(output, input.toSymbolReference());
            } else {
                Expression cast = noTruncationCast(input.toSymbolReference(), queryType, tableType);
                assignments.put(output, cast);
            }
            insertedColumnsBuilder.add(column);
        }
    }
    ProjectNode projectNode = new ProjectNode(idAllocator.getNextId(), plan.getRoot(), assignments.build());
    List<ColumnMetadata> insertedColumns = insertedColumnsBuilder.build();
    List<Field> fields = insertedColumns.stream().map(column -> Field.newUnqualified(column.getName(), column.getType())).collect(toImmutableList());
    Scope scope = Scope.builder().withRelationType(RelationId.anonymous(), new RelationType(fields)).build();
    plan = new RelationPlan(projectNode, scope, projectNode.getOutputSymbols(), Optional.empty());
    plan = planner.addRowFilters(table, plan, failIfPredicateIsNotMeet(metadata, session, PERMISSION_DENIED, AccessDeniedException.PREFIX + "Cannot insert row that does not match to a row filter"), node -> {
        Scope accessControlScope = analysis.getAccessControlScope(table);
        // hidden fields are not accessible in insert
        return Scope.builder().like(accessControlScope).withRelationType(accessControlScope.getRelationId(), accessControlScope.getRelationType().withOnlyVisibleFields()).build();
    });
    List<String> insertedTableColumnNames = insertedColumns.stream().map(ColumnMetadata::getName).collect(toImmutableList());
    String catalogName = tableHandle.getCatalogName().getCatalogName();
    TableStatisticsMetadata statisticsMetadata = metadata.getStatisticsCollectionMetadataForWrite(session, catalogName, tableMetadata.getMetadata());
    if (materializedViewRefreshWriterTarget.isPresent()) {
        return createTableWriterPlan(analysis, plan.getRoot(), plan.getFieldMappings(), materializedViewRefreshWriterTarget.get(), insertedTableColumnNames, insertedColumns, newTableLayout, statisticsMetadata);
    }
    InsertReference insertTarget = new InsertReference(tableHandle, insertedTableColumnNames.stream().map(columns::get).collect(toImmutableList()));
    return createTableWriterPlan(analysis, plan.getRoot(), plan.getFieldMappings(), insertTarget, insertedTableColumnNames, insertedColumns, newTableLayout, statisticsMetadata);
}
Also used : Cast(io.trino.sql.tree.Cast) FIXED_HASH_DISTRIBUTION(io.trino.sql.planner.SystemPartitioningHandle.FIXED_HASH_DISTRIBUTION) CostProvider(io.trino.cost.CostProvider) TypeSignatureProvider.fromTypes(io.trino.sql.analyzer.TypeSignatureProvider.fromTypes) Delete(io.trino.sql.tree.Delete) InsertReference(io.trino.sql.planner.plan.TableWriterNode.InsertReference) PlanNode(io.trino.sql.planner.plan.PlanNode) NOT_SUPPORTED(io.trino.spi.StandardErrorCode.NOT_SUPPORTED) LongLiteral(io.trino.sql.tree.LongLiteral) Map(java.util.Map) OutputNode(io.trino.sql.planner.plan.OutputNode) TableScanNode(io.trino.sql.planner.plan.TableScanNode) ExplainAnalyzeNode(io.trino.sql.planner.plan.ExplainAnalyzeNode) ExplainAnalyze(io.trino.sql.tree.ExplainAnalyze) Statement(io.trino.sql.tree.Statement) SystemSessionProperties.isCollectPlanStatisticsForAllQueries(io.trino.SystemSessionProperties.isCollectPlanStatisticsForAllQueries) StatisticsWriterNode(io.trino.sql.planner.plan.StatisticsWriterNode) TableExecute(io.trino.sql.tree.TableExecute) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Assignments(io.trino.sql.planner.plan.Assignments) Set(java.util.Set) PlanSanityChecker(io.trino.sql.planner.sanity.PlanSanityChecker) RelationType(io.trino.sql.analyzer.RelationType) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) PlanBuilder.newPlanBuilder(io.trino.sql.planner.PlanBuilder.newPlanBuilder) CachingStatsProvider(io.trino.cost.CachingStatsProvider) ValuesNode(io.trino.sql.planner.plan.ValuesNode) Session(io.trino.Session) AccessDeniedException(io.trino.spi.security.AccessDeniedException) TableExecuteNode(io.trino.sql.planner.plan.TableExecuteNode) PlanPrinter(io.trino.sql.planner.planprinter.PlanPrinter) QueryPlanner.visibleFields(io.trino.sql.planner.QueryPlanner.visibleFields) CreateReference(io.trino.sql.planner.plan.TableWriterNode.CreateReference) ColumnMetadata(io.trino.spi.connector.ColumnMetadata) LimitNode(io.trino.sql.planner.plan.LimitNode) TableLayout(io.trino.metadata.TableLayout) TypeCoercion(io.trino.type.TypeCoercion) BOOLEAN(io.trino.spi.type.BooleanType.BOOLEAN) ConnectorTableMetadata(io.trino.spi.connector.ConnectorTableMetadata) StatsAndCosts(io.trino.cost.StatsAndCosts) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) VARCHAR(io.trino.spi.type.VarcharType.VARCHAR) MetadataUtil.createQualifiedObjectName(io.trino.metadata.MetadataUtil.createQualifiedObjectName) PlanOptimizer(io.trino.sql.planner.optimizations.PlanOptimizer) NodeRef(io.trino.sql.tree.NodeRef) ColumnHandle(io.trino.spi.connector.ColumnHandle) AggregationNode(io.trino.sql.planner.plan.AggregationNode) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) VARBINARY(io.trino.spi.type.VarbinaryType.VARBINARY) Query(io.trino.sql.tree.Query) StringLiteral(io.trino.sql.tree.StringLiteral) TableStatisticAggregation(io.trino.sql.planner.StatisticsAggregationPlanner.TableStatisticAggregation) AggregationNode.singleGroupingSet(io.trino.sql.planner.plan.AggregationNode.singleGroupingSet) TableHandle(io.trino.metadata.TableHandle) QualifiedObjectName(io.trino.metadata.QualifiedObjectName) CharType(io.trino.spi.type.CharType) Table(io.trino.sql.tree.Table) TableFinishNode(io.trino.sql.planner.plan.TableFinishNode) TableStatisticsMetadata(io.trino.spi.statistics.TableStatisticsMetadata) UnknownType(io.trino.type.UnknownType) RefreshMaterializedView(io.trino.sql.tree.RefreshMaterializedView) TableWriterNode(io.trino.sql.planner.plan.TableWriterNode) OPTIMIZED_AND_VALIDATED(io.trino.sql.planner.LogicalPlanner.Stage.OPTIMIZED_AND_VALIDATED) Scope(io.trino.sql.analyzer.Scope) FilterNode(io.trino.sql.planner.plan.FilterNode) StatsCalculator(io.trino.cost.StatsCalculator) LambdaArgumentDeclaration(io.trino.sql.tree.LambdaArgumentDeclaration) RelationId(io.trino.sql.analyzer.RelationId) DeleteNode(io.trino.sql.planner.plan.DeleteNode) Update(io.trino.sql.tree.Update) INTEGER(io.trino.spi.type.IntegerType.INTEGER) FunctionCall(io.trino.sql.tree.FunctionCall) ImmutableMap(com.google.common.collect.ImmutableMap) ResolvedFunction(io.trino.metadata.ResolvedFunction) TypeSignatureTranslator.toSqlType(io.trino.sql.analyzer.TypeSignatureTranslator.toSqlType) TrinoException(io.trino.spi.TrinoException) ROW_COUNT(io.trino.spi.statistics.TableStatisticType.ROW_COUNT) TableExecuteHandle(io.trino.metadata.TableExecuteHandle) StatsProvider(io.trino.cost.StatsProvider) ComparisonExpression(io.trino.sql.tree.ComparisonExpression) String.format(java.lang.String.format) Preconditions.checkState(com.google.common.base.Preconditions.checkState) CoalesceExpression(io.trino.sql.tree.CoalesceExpression) GenericLiteral(io.trino.sql.tree.GenericLiteral) Objects(java.util.Objects) TableMetadata(io.trino.metadata.TableMetadata) List(java.util.List) IfExpression(io.trino.sql.tree.IfExpression) BIGINT(io.trino.spi.type.BigintType.BIGINT) StandardErrorCode(io.trino.spi.StandardErrorCode) Analyze(io.trino.sql.tree.Analyze) Entry(java.util.Map.Entry) Optional(java.util.Optional) Expression(io.trino.sql.tree.Expression) PlannerContext(io.trino.sql.PlannerContext) Analysis(io.trino.sql.analyzer.Analysis) PERMISSION_DENIED(io.trino.spi.StandardErrorCode.PERMISSION_DENIED) Logger(io.airlift.log.Logger) Type(io.trino.spi.type.Type) CreateTableAsSelect(io.trino.sql.tree.CreateTableAsSelect) HashMap(java.util.HashMap) StatisticAggregations(io.trino.sql.planner.plan.StatisticAggregations) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) OPTIMIZED(io.trino.sql.planner.LogicalPlanner.Stage.OPTIMIZED) Function(java.util.function.Function) Cast(io.trino.sql.tree.Cast) VarcharType(io.trino.spi.type.VarcharType) CachingCostProvider(io.trino.cost.CachingCostProvider) ImmutableList(com.google.common.collect.ImmutableList) Verify.verify(com.google.common.base.Verify.verify) Objects.requireNonNull(java.util.Objects.requireNonNull) RefreshMaterializedViewNode(io.trino.sql.planner.plan.RefreshMaterializedViewNode) NullLiteral(io.trino.sql.tree.NullLiteral) Field(io.trino.sql.analyzer.Field) GREATER_THAN_OR_EQUAL(io.trino.sql.tree.ComparisonExpression.Operator.GREATER_THAN_OR_EQUAL) ProjectNode(io.trino.sql.planner.plan.ProjectNode) DISTRIBUTED_PLAN_SANITY_CHECKER(io.trino.sql.planner.sanity.PlanSanityChecker.DISTRIBUTED_PLAN_SANITY_CHECKER) WriterTarget(io.trino.sql.planner.plan.TableWriterNode.WriterTarget) TRUE_LITERAL(io.trino.sql.tree.BooleanLiteral.TRUE_LITERAL) UpdateNode(io.trino.sql.planner.plan.UpdateNode) QualifiedName(io.trino.sql.tree.QualifiedName) CostCalculator(io.trino.cost.CostCalculator) WarningCollector(io.trino.execution.warnings.WarningCollector) Row(io.trino.sql.tree.Row) Metadata(io.trino.metadata.Metadata) Insert(io.trino.sql.tree.Insert) Streams.zip(com.google.common.collect.Streams.zip) TableStatisticsMetadata(io.trino.spi.statistics.TableStatisticsMetadata) ColumnMetadata(io.trino.spi.connector.ColumnMetadata) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) Assignments(io.trino.sql.planner.plan.Assignments) InsertReference(io.trino.sql.planner.plan.TableWriterNode.InsertReference) NodeRef(io.trino.sql.tree.NodeRef) Field(io.trino.sql.analyzer.Field) RelationType(io.trino.sql.analyzer.RelationType) ConnectorTableMetadata(io.trino.spi.connector.ConnectorTableMetadata) TableMetadata(io.trino.metadata.TableMetadata) ColumnHandle(io.trino.spi.connector.ColumnHandle) RelationType(io.trino.sql.analyzer.RelationType) CharType(io.trino.spi.type.CharType) UnknownType(io.trino.type.UnknownType) TypeSignatureTranslator.toSqlType(io.trino.sql.analyzer.TypeSignatureTranslator.toSqlType) Type(io.trino.spi.type.Type) VarcharType(io.trino.spi.type.VarcharType) Scope(io.trino.sql.analyzer.Scope) ComparisonExpression(io.trino.sql.tree.ComparisonExpression) CoalesceExpression(io.trino.sql.tree.CoalesceExpression) IfExpression(io.trino.sql.tree.IfExpression) Expression(io.trino.sql.tree.Expression) ProjectNode(io.trino.sql.planner.plan.ProjectNode) NullLiteral(io.trino.sql.tree.NullLiteral)

Aggregations

Metadata (io.trino.metadata.Metadata)50 Session (io.trino.Session)35 List (java.util.List)34 Optional (java.util.Optional)31 Objects.requireNonNull (java.util.Objects.requireNonNull)30 PlanNode (io.trino.sql.planner.plan.PlanNode)22 Expression (io.trino.sql.tree.Expression)21 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)20 Set (java.util.Set)19 Preconditions.checkState (com.google.common.base.Preconditions.checkState)18 Map (java.util.Map)16 ImmutableList (com.google.common.collect.ImmutableList)15 MoreObjects.toStringHelper (com.google.common.base.MoreObjects.toStringHelper)14 StatsProvider (io.trino.cost.StatsProvider)14 QualifiedObjectName (io.trino.metadata.QualifiedObjectName)14 Symbol (io.trino.sql.planner.Symbol)14 ImmutableMap (com.google.common.collect.ImmutableMap)13 ImmutableSet (com.google.common.collect.ImmutableSet)13 TableHandle (io.trino.metadata.TableHandle)13 NO_MATCH (io.trino.sql.planner.assertions.MatchResult.NO_MATCH)13