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());
}
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;
}
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;
}
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;
}
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();
}
Aggregations