Search in sources :

Example 26 with Symbol

use of com.facebook.presto.sql.planner.Symbol in project presto by prestodb.

the class TestSourcePartitionedScheduler method createPlan.

private static StageExecutionPlan createPlan(ConnectorSplitSource splitSource) {
    Symbol symbol = new Symbol("column");
    // table scan with splitCount splits
    PlanNodeId tableScanNodeId = new PlanNodeId("plan_id");
    TableScanNode tableScan = new TableScanNode(tableScanNodeId, new TableHandle(CONNECTOR_ID, new TestingTableHandle()), ImmutableList.of(symbol), ImmutableMap.of(symbol, new TestingColumnHandle("column")), Optional.empty(), TupleDomain.all(), null);
    RemoteSourceNode remote = new RemoteSourceNode(new PlanNodeId("remote_id"), new PlanFragmentId("plan_fragment_id"), ImmutableList.of());
    PlanFragment testFragment = new PlanFragment(new PlanFragmentId("plan_id"), new JoinNode(new PlanNodeId("join_id"), INNER, tableScan, remote, ImmutableList.of(), ImmutableList.<Symbol>builder().addAll(tableScan.getOutputSymbols()).addAll(remote.getOutputSymbols()).build(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(JoinNode.DistributionType.PARTITIONED)), ImmutableMap.of(symbol, VARCHAR), SOURCE_DISTRIBUTION, ImmutableList.of(tableScanNodeId), new PartitioningScheme(Partitioning.create(SINGLE_DISTRIBUTION, ImmutableList.of()), ImmutableList.of(symbol)));
    return new StageExecutionPlan(testFragment, ImmutableMap.of(tableScanNodeId, new ConnectorAwareSplitSource(CONNECTOR_ID, TestingTransactionHandle.create(), splitSource)), ImmutableList.of());
}
Also used : Symbol(com.facebook.presto.sql.planner.Symbol) TestingTableHandle(com.facebook.presto.sql.planner.TestingTableHandle) JoinNode(com.facebook.presto.sql.planner.plan.JoinNode) PartitioningScheme(com.facebook.presto.sql.planner.PartitioningScheme) StageExecutionPlan(com.facebook.presto.sql.planner.StageExecutionPlan) PlanFragment(com.facebook.presto.sql.planner.PlanFragment) ConnectorAwareSplitSource(com.facebook.presto.split.ConnectorAwareSplitSource) PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) TestingColumnHandle(com.facebook.presto.sql.planner.TestingColumnHandle) RemoteSourceNode(com.facebook.presto.sql.planner.plan.RemoteSourceNode) TableScanNode(com.facebook.presto.sql.planner.plan.TableScanNode) TestingTableHandle(com.facebook.presto.sql.planner.TestingTableHandle) TableHandle(com.facebook.presto.metadata.TableHandle) PlanFragmentId(com.facebook.presto.sql.planner.plan.PlanFragmentId)

Example 27 with Symbol

use of com.facebook.presto.sql.planner.Symbol in project presto by prestodb.

the class PlanBuilder method symbol.

public Symbol symbol(String name, Type type) {
    Symbol symbol = new Symbol(name);
    Type old = symbols.get(symbol);
    if (old != null && !old.equals(type)) {
        throw new IllegalArgumentException(format("Symbol '%s' already registered with type '%s'", name, old));
    }
    if (old == null) {
        symbols.put(symbol, type);
    }
    return symbol;
}
Also used : Type(com.facebook.presto.spi.type.Type) Symbol(com.facebook.presto.sql.planner.Symbol)

Example 28 with Symbol

use of com.facebook.presto.sql.planner.Symbol in project presto by prestodb.

the class WindowFunctionMatcher method getAssignedSymbol.

@Override
public Optional<Symbol> getAssignedSymbol(PlanNode node, Session session, Metadata metadata, SymbolAliases symbolAliases) {
    Optional<Symbol> result = Optional.empty();
    if (!(node instanceof WindowNode)) {
        return result;
    }
    WindowNode windowNode = (WindowNode) node;
    FunctionCall expectedCall = callMaker.getExpectedValue(symbolAliases);
    for (Map.Entry<Symbol, WindowNode.Function> assignment : windowNode.getWindowFunctions().entrySet()) {
        if (expectedCall.equals(assignment.getValue().getFunctionCall())) {
            checkState(!result.isPresent(), "Ambiguous function calls in %s", windowNode);
            result = Optional.of(assignment.getKey());
        }
    }
    return result;
}
Also used : WindowNode(com.facebook.presto.sql.planner.plan.WindowNode) Symbol(com.facebook.presto.sql.planner.Symbol) FunctionCall(com.facebook.presto.sql.tree.FunctionCall) Map(java.util.Map)

Example 29 with Symbol

use of com.facebook.presto.sql.planner.Symbol in project presto by prestodb.

the class TestStageStateMachine method createValuesPlan.

private static PlanFragment createValuesPlan() {
    Symbol symbol = new Symbol("column");
    PlanNodeId valuesNodeId = new PlanNodeId("plan");
    PlanFragment planFragment = new PlanFragment(new PlanFragmentId("plan"), new ValuesNode(valuesNodeId, ImmutableList.of(symbol), ImmutableList.of(ImmutableList.of(new StringLiteral("foo")))), ImmutableMap.of(symbol, VARCHAR), SOURCE_DISTRIBUTION, ImmutableList.of(valuesNodeId), new PartitioningScheme(Partitioning.create(SINGLE_DISTRIBUTION, ImmutableList.of()), ImmutableList.of(symbol)));
    return planFragment;
}
Also used : PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) ValuesNode(com.facebook.presto.sql.planner.plan.ValuesNode) StringLiteral(com.facebook.presto.sql.tree.StringLiteral) Symbol(com.facebook.presto.sql.planner.Symbol) PartitioningScheme(com.facebook.presto.sql.planner.PartitioningScheme) PlanFragmentId(com.facebook.presto.sql.planner.plan.PlanFragmentId) PlanFragment(com.facebook.presto.sql.planner.PlanFragment)

Example 30 with Symbol

use of com.facebook.presto.sql.planner.Symbol in project presto by prestodb.

the class SymbolMapper method mapAndDistinctSymbol.

private List<Symbol> mapAndDistinctSymbol(List<Symbol> outputs) {
    Set<Symbol> added = new HashSet<>();
    ImmutableList.Builder<Symbol> builder = ImmutableList.builder();
    for (Symbol symbol : outputs) {
        Symbol canonical = map(symbol);
        if (added.add(canonical)) {
            builder.add(canonical);
        }
    }
    return builder.build();
}
Also used : Symbol(com.facebook.presto.sql.planner.Symbol) ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) HashSet(java.util.HashSet)

Aggregations

Symbol (com.facebook.presto.sql.planner.Symbol)38 List (java.util.List)13 Map (java.util.Map)13 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)12 Optional (java.util.Optional)12 Session (com.facebook.presto.Session)9 ImmutableList (com.google.common.collect.ImmutableList)9 Metadata (com.facebook.presto.metadata.Metadata)8 Expression (com.facebook.presto.sql.tree.Expression)8 Preconditions.checkState (com.google.common.base.Preconditions.checkState)8 AggregationNode (com.facebook.presto.sql.planner.plan.AggregationNode)7 PlanNode (com.facebook.presto.spi.plan.PlanNode)6 NO_MATCH (com.facebook.presto.sql.planner.assertions.MatchResult.NO_MATCH)6 MatchResult.match (com.facebook.presto.sql.planner.assertions.MatchResult.match)6 ProjectNode (com.facebook.presto.sql.planner.plan.ProjectNode)6 FunctionCall (com.facebook.presto.sql.tree.FunctionCall)6 StatsProvider (com.facebook.presto.cost.StatsProvider)5 PlanNode (com.facebook.presto.sql.planner.plan.PlanNode)5 WindowNode (com.facebook.presto.sql.planner.plan.WindowNode)5 MoreObjects.toStringHelper (com.google.common.base.MoreObjects.toStringHelper)5