public ValuesNode values(PlanNodeId id, List<Symbol> columns, List<List<Expression>> rows) { return new ValuesNode(id, columns, rows); }
private RelationPlan planImplicitTable() { List<Expression> emptyRow = ImmutableList.of(); Scope scope = Scope.create(); return new RelationPlan( new ValuesNode(idAllocator.getNextId(), ImmutableList.of(), ImmutableList.of(emptyRow)), scope, ImmutableList.of()); }
private RelationPlan planImplicitTable() { List<Expression> emptyRow = ImmutableList.of(); Scope scope = Scope.create(); return new RelationPlan( new ValuesNode(idAllocator.getNextId(), ImmutableList.of(), ImmutableList.of(emptyRow)), scope, ImmutableList.of()); }
@Override public Result apply(LimitNode limit, Captures captures, Context context) { return Result.ofPlanNode(new ValuesNode(limit.getId(), limit.getOutputSymbols(), ImmutableList.of())); } }
@Override public Result apply(SampleNode sample, Captures captures, Context context) { return Result.ofPlanNode(new ValuesNode(sample.getId(), sample.getOutputSymbols(), ImmutableList.of())); } }
@Override public Result apply(SampleNode sample, Captures captures, Context context) { return Result.ofPlanNode(new ValuesNode(sample.getId(), sample.getOutputSymbols(), ImmutableList.of())); } }
@Override public Result apply(LimitNode limit, Captures captures, Context context) { return Result.ofPlanNode(new ValuesNode(limit.getId(), limit.getOutputSymbols(), ImmutableList.of())); } }
@Override public PlanNode visitValues(ValuesNode node, RewriteContext<Void> context) { List<List<Expression>> canonicalizedRows = node.getRows().stream() .map(this::canonicalize) .collect(toImmutableList()); List<Symbol> canonicalizedOutputSymbols = canonicalizeAndDistinct(node.getOutputSymbols()); checkState(node.getOutputSymbols().size() == canonicalizedOutputSymbols.size(), "Values output symbols were pruned"); return new ValuesNode( node.getId(), canonicalizedOutputSymbols, canonicalizedRows); }
public PlanNode planStatement(Analysis analysis, Statement statement) { if (statement instanceof CreateTableAsSelect && analysis.isCreateTableAsSelectNoOp()) { checkState(analysis.getCreateTableDestination().isPresent(), "Table destination is missing"); Symbol symbol = symbolAllocator.newSymbol("rows", BIGINT); PlanNode source = new ValuesNode(idAllocator.getNextId(), ImmutableList.of(symbol), ImmutableList.of(ImmutableList.of(new LongLiteral("0")))); return new OutputNode(idAllocator.getNextId(), source, ImmutableList.of("rows"), ImmutableList.of(symbol)); } return createOutputPlan(planStatementWithoutOutput(analysis, statement), analysis); }
@Override public Result apply(TableFinishNode node, Captures captures, Context context) { return Result.ofPlanNode( new ValuesNode( node.getId(), node.getOutputSymbols(), ImmutableList.of(ImmutableList.of(new LongLiteral("0"))))); } }
public PlanNode planStatement(Analysis analysis, Statement statement) { if (statement instanceof CreateTableAsSelect && analysis.isCreateTableAsSelectNoOp()) { checkState(analysis.getCreateTableDestination().isPresent(), "Table destination is missing"); Symbol symbol = symbolAllocator.newSymbol("rows", BIGINT); PlanNode source = new ValuesNode(idAllocator.getNextId(), ImmutableList.of(symbol), ImmutableList.of(ImmutableList.of(new LongLiteral("0")))); return new OutputNode(idAllocator.getNextId(), source, ImmutableList.of("rows"), ImmutableList.of(symbol)); } return createOutputPlan(planStatementWithoutOutput(analysis, statement), analysis); }
@Override public Result apply(TableFinishNode node, Captures captures, Context context) { return Result.ofPlanNode( new ValuesNode( node.getId(), node.getOutputSymbols(), ImmutableList.of(ImmutableList.of(new LongLiteral("0"))))); } }
private ValuesNode values(String... symbols) { return new ValuesNode( idAllocator.getNextId(), Arrays.stream(symbols).map(Symbol::new).collect(toImmutableList()), ImmutableList.of()); } }
private ValuesNode values(String... symbols) { return new ValuesNode( idAllocator.getNextId(), Arrays.stream(symbols).map(Symbol::new).collect(toImmutableList()), ImmutableList.of()); } }
@Test public void testValidateSuccessful() { // random seemingly valid plan PlanNode root = new OutputNode(idAllocator.getNextId(), new ProjectNode(idAllocator.getNextId(), new ValuesNode( idAllocator.getNextId(), ImmutableList.of(), ImmutableList.of()), Assignments.of() ), ImmutableList.of(), ImmutableList.of()); new VerifyOnlyOneOutputNode().validate(root, null, null, null, null, WarningCollector.NOOP); }
@Test public void testValidateSuccessful() { // random seemingly valid plan PlanNode root = new OutputNode(idAllocator.getNextId(), new ProjectNode(idAllocator.getNextId(), new ValuesNode( idAllocator.getNextId(), ImmutableList.of(), ImmutableList.of()), Assignments.of() ), ImmutableList.of(), ImmutableList.of()); new VerifyOnlyOneOutputNode().validate(root, null, null, null, null, WarningCollector.NOOP); }
@BeforeClass public void setUp() { symbolAllocator = new SymbolAllocator(); columnA = symbolAllocator.newSymbol("a", BIGINT); columnB = symbolAllocator.newSymbol("b", BIGINT); columnC = symbolAllocator.newSymbol("c", BIGINT); sourceNode = new ValuesNode( newId(), ImmutableList.of(columnA, columnB, columnC), ImmutableList.of()); }
@BeforeClass public void setUp() { symbolAllocator = new SymbolAllocator(); columnA = symbolAllocator.newSymbol("a", BIGINT); columnB = symbolAllocator.newSymbol("b", BIGINT); columnC = symbolAllocator.newSymbol("c", BIGINT); sourceNode = new ValuesNode( newId(), ImmutableList.of(columnA, columnB, columnC), ImmutableList.of()); }
@Override public Result apply(FilterNode filterNode, Captures captures, Context context) { Expression predicate = filterNode.getPredicate(); if (predicate.equals(TRUE_LITERAL)) { return Result.ofPlanNode(filterNode.getSource()); } if (predicate.equals(FALSE_LITERAL)) { return Result.ofPlanNode(new ValuesNode(context.getIdAllocator().getNextId(), filterNode.getOutputSymbols(), emptyList())); } return Result.empty(); } }
@Override public Result apply(FilterNode filterNode, Captures captures, Context context) { Expression predicate = filterNode.getPredicate(); if (predicate.equals(TRUE_LITERAL)) { return Result.ofPlanNode(filterNode.getSource()); } if (predicate.equals(FALSE_LITERAL)) { return Result.ofPlanNode(new ValuesNode(context.getIdAllocator().getNextId(), filterNode.getOutputSymbols(), emptyList())); } return Result.empty(); } }