Search in sources :

Example 1 with FlinkPhysicalRel

use of org.apache.flink.table.planner.plan.nodes.physical.FlinkPhysicalRel in project flink by apache.

the class ExecNodeGraphGenerator method generate.

private ExecNode<?> generate(FlinkPhysicalRel rel) {
    ExecNode<?> execNode = visitedRels.get(rel);
    if (execNode != null) {
        return execNode;
    }
    if (rel instanceof CommonIntermediateTableScan) {
        throw new TableException("Intermediate RelNode can't be converted to ExecNode.");
    }
    List<ExecNode<?>> inputNodes = new ArrayList<>();
    for (RelNode input : rel.getInputs()) {
        inputNodes.add(generate((FlinkPhysicalRel) input));
    }
    execNode = rel.translateToExecNode();
    // connects the input nodes
    List<ExecEdge> inputEdges = new ArrayList<>(inputNodes.size());
    for (ExecNode<?> inputNode : inputNodes) {
        inputEdges.add(ExecEdge.builder().source(inputNode).target(execNode).build());
    }
    execNode.setInputEdges(inputEdges);
    visitedRels.put(rel, execNode);
    return execNode;
}
Also used : CommonIntermediateTableScan(org.apache.flink.table.planner.plan.nodes.common.CommonIntermediateTableScan) TableException(org.apache.flink.table.api.TableException) RelNode(org.apache.calcite.rel.RelNode) ArrayList(java.util.ArrayList) FlinkPhysicalRel(org.apache.flink.table.planner.plan.nodes.physical.FlinkPhysicalRel)

Example 2 with FlinkPhysicalRel

use of org.apache.flink.table.planner.plan.nodes.physical.FlinkPhysicalRel in project flink by apache.

the class MultipleInputNodeCreationProcessorTest method assertChainableSource.

private void assertChainableSource(String name, TableTestUtil util, boolean expected) {
    String sql = "SELECT * FROM " + name;
    Table table = util.tableEnv().sqlQuery(sql);
    RelNode relNode = TableTestUtil.toRelNode(table);
    FlinkPhysicalRel optimizedRel = (FlinkPhysicalRel) util.getPlanner().optimize(relNode);
    ExecNodeGraphGenerator generator = new ExecNodeGraphGenerator();
    ExecNodeGraph execGraph = generator.generate(Collections.singletonList(optimizedRel));
    ExecNode<?> execNode = execGraph.getRootNodes().get(0);
    while (!execNode.getInputEdges().isEmpty()) {
        execNode = execNode.getInputEdges().get(0).getSource();
    }
    ProcessorContext context = new ProcessorContext(util.getPlanner());
    Assert.assertEquals(expected, MultipleInputNodeCreationProcessor.isChainableSource(execNode, context));
}
Also used : ExecNodeGraph(org.apache.flink.table.planner.plan.nodes.exec.ExecNodeGraph) Table(org.apache.flink.table.api.Table) RelNode(org.apache.calcite.rel.RelNode) ExecNodeGraphGenerator(org.apache.flink.table.planner.plan.nodes.exec.ExecNodeGraphGenerator) FlinkPhysicalRel(org.apache.flink.table.planner.plan.nodes.physical.FlinkPhysicalRel)

Aggregations

RelNode (org.apache.calcite.rel.RelNode)2 FlinkPhysicalRel (org.apache.flink.table.planner.plan.nodes.physical.FlinkPhysicalRel)2 ArrayList (java.util.ArrayList)1 Table (org.apache.flink.table.api.Table)1 TableException (org.apache.flink.table.api.TableException)1 CommonIntermediateTableScan (org.apache.flink.table.planner.plan.nodes.common.CommonIntermediateTableScan)1 ExecNodeGraph (org.apache.flink.table.planner.plan.nodes.exec.ExecNodeGraph)1 ExecNodeGraphGenerator (org.apache.flink.table.planner.plan.nodes.exec.ExecNodeGraphGenerator)1