@Test public final void testImplicityJoinPlan() throws CloneNotSupportedException, PlanningException { Expr expr = sqlAnalyzer.parse(QUERIES[1]); LogicalPlan planNode = planner.createPlan(expr); LogicalNode plan = planNode.getRootBlock().getRoot(); assertEquals(NodeType.ROOT, plan.getType()); LogicalRootNode root = (LogicalRootNode) plan; testJsonSerDerObject(root); TestLogicalNode.testCloneLogicalNode(root); Schema expectedSchema = new Schema(); expectedSchema.addColumn("name", Type.TEXT); expectedSchema.addColumn("empid", Type.INT4); expectedSchema.addColumn("deptname", Type.TEXT); expectedSchema.addColumn("manager", Type.TEXT); for (int i = 0; i < expectedSchema.size(); i++) { Column found = root.getOutSchema().getColumn(expectedSchema.getColumn(i).getSimpleName()); assertEquals(expectedSchema.getColumn(i).getDataType(), found.getDataType()); } assertEquals(NodeType.PROJECTION, root.getChild().getType()); ProjectionNode projNode = root.getChild(); assertEquals(NodeType.JOIN, projNode.getChild().getType()); JoinNode joinNode = projNode.getChild(); assertEquals(NodeType.SCAN, joinNode.getLeftChild().getType()); ScanNode leftNode = joinNode.getLeftChild(); assertEquals("employee", leftNode.getTableName()); assertEquals(NodeType.SCAN, joinNode.getRightChild().getType()); ScanNode rightNode = joinNode.getRightChild(); assertEquals("dept", rightNode.getTableName()); expr = sqlAnalyzer.parse(QUERIES[2]); plan = planner.createPlan(expr).getRootBlock().getRoot(); testJsonSerDerObject(plan); TestLogicalNode.testCloneLogicalNode(plan); expectedSchema.addColumn("score", Type.INT4); assertSchema(expectedSchema, plan.getOutSchema()); assertEquals(NodeType.ROOT, plan.getType()); root = (LogicalRootNode) plan; assertEquals(NodeType.PROJECTION, root.getChild().getType()); projNode = root.getChild(); assertEquals(NodeType.JOIN, projNode.getChild().getType()); joinNode = projNode.getChild(); assertEquals(NodeType.JOIN, joinNode.getLeftChild().getType()); assertEquals(NodeType.SCAN, joinNode.getRightChild().getType()); ScanNode scan1 = joinNode.getRightChild(); assertEquals("score", scan1.getTableName()); JoinNode leftNode2 = joinNode.getLeftChild(); assertEquals(NodeType.JOIN, leftNode2.getType()); assertEquals(NodeType.SCAN, leftNode2.getLeftChild().getType()); ScanNode leftScan = leftNode2.getLeftChild(); assertEquals("employee", leftScan.getTableName()); assertEquals(NodeType.SCAN, leftNode2.getRightChild().getType()); ScanNode rightScan = leftNode2.getRightChild(); assertEquals("dept", rightScan.getTableName()); }
public LogicalPlan createPlan(Expr expr) throws PlanningException { return createPlan(expr, false); }
LogicalPlanner extends BaseAlgebraVisitor<LogicalPlanner.PlanContext, LogicalNode> { public LogicalPlan createPlan(Expr expr) throws PlanningException { return createPlan(expr, false); } }
LogicalPlanner extends BaseAlgebraVisitor<LogicalPlanner.PlanContext, LogicalNode> { public LogicalPlan createPlan(Expr expr) throws PlanningException { return createPlan(expr, false); } LogicalPlanner(CatalogService catalog); }
LogicalPlanner extends BaseAlgebraVisitor<LogicalPlanner.PlanContext, LogicalNode> { public LogicalPlan createPlan(Expr expr) throws PlanningException { return createPlan(expr, false); } LogicalPlanner(CatalogService catalog); LogicalPlan createPlan(Expr expr); @VisibleForTesting LogicalPlan createPlan(Expr expr, boolean debug); ExprAnnotator getExprAnnotator(); void preHook(PlanContext context, Stack<Expr> stack, Expr expr); LogicalNode postHook(PlanContext context, Stack<Expr> stack, Expr expr, LogicalNode current); @Override LogicalNode visitProjection(PlanContext context, Stack<Expr> stack, Projection projection); static void verifyProjectedFields(QueryBlock block, Projectable projectable); @Override LimitNode visitLimit(PlanContext context, Stack<Expr> stack, Limit limit); @Override SortNode visitSort(PlanContext context, Stack<Expr> stack, Sort sort); @Override LogicalNode visitHaving(PlanContext context, Stack<Expr> stack, Having expr); @Override LogicalNode visitGroupBy(PlanContext context, Stack<Expr> stack, Aggregation aggregation); static List<Column[]> generateCuboids(Column[] columns); @Override SelectionNode visitFilter(PlanContext context, Stack<Expr> stack, Selection selection); @Override LogicalNode visitJoin(PlanContext context, Stack<Expr> stack, Join join); @Override LogicalNode visitRelationList(PlanContext context, Stack<Expr> stack, RelationList relations); @Override ScanNode visitRelation(PlanContext context, Stack<Expr> stack, Relation expr); TableSubQueryNode visitTableSubQuery(PlanContext context, Stack<Expr> stack, TablePrimarySubQuery expr); @Override LogicalNode visitUnion(PlanContext context, Stack<Expr> stack, SetOperation setOperation); @Override LogicalNode visitExcept(PlanContext context, Stack<Expr> stack, SetOperation setOperation); @Override LogicalNode visitIntersect(PlanContext context, Stack<Expr> stack, SetOperation setOperation); LogicalNode visitInsert(PlanContext context, Stack<Expr> stack, Insert expr); @Override LogicalNode visitCreateTable(PlanContext context, Stack<Expr> stack, CreateTable expr); @Override LogicalNode visitDropTable(PlanContext context, Stack<Expr> stack, DropTable dropTable); static boolean checkIfBeEvaluatedAtGroupBy(EvalNode evalNode, GroupbyNode node); static boolean checkIfBeEvaluatedAtJoin(QueryBlock block, EvalNode evalNode, JoinNode node,
                                                 boolean isTopMostJoin); static boolean checkIfBeEvaluatedAtRelation(QueryBlock block, EvalNode evalNode, RelationNode node); static boolean checkIfBeEvaluatedAtThis(EvalNode evalNode, LogicalNode node); }
LogicalPlanner extends BaseAlgebraVisitor<LogicalPlanner.PlanContext, LogicalNode> { public LogicalPlan createPlan(Expr expr) throws PlanningException { return createPlan(expr, false); } LogicalPlanner(CatalogService catalog); LogicalPlan createPlan(Expr expr); @VisibleForTesting LogicalPlan createPlan(Expr expr, boolean debug); ExprAnnotator getExprAnnotator(); void preHook(PlanContext context, Stack<Expr> stack, Expr expr); LogicalNode postHook(PlanContext context, Stack<Expr> stack, Expr expr, LogicalNode current); @Override LogicalNode visitProjection(PlanContext context, Stack<Expr> stack, Projection projection); static void verifyProjectedFields(QueryBlock block, Projectable projectable); @Override LimitNode visitLimit(PlanContext context, Stack<Expr> stack, Limit limit); @Override SortNode visitSort(PlanContext context, Stack<Expr> stack, Sort sort); @Override LogicalNode visitHaving(PlanContext context, Stack<Expr> stack, Having expr); @Override LogicalNode visitGroupBy(PlanContext context, Stack<Expr> stack, Aggregation aggregation); static List<Column[]> generateCuboids(Column[] columns); @Override SelectionNode visitFilter(PlanContext context, Stack<Expr> stack, Selection selection); @Override LogicalNode visitJoin(PlanContext context, Stack<Expr> stack, Join join); @Override LogicalNode visitRelationList(PlanContext context, Stack<Expr> stack, RelationList relations); @Override ScanNode visitRelation(PlanContext context, Stack<Expr> stack, Relation expr); TableSubQueryNode visitTableSubQuery(PlanContext context, Stack<Expr> stack, TablePrimarySubQuery expr); @Override LogicalNode visitUnion(PlanContext context, Stack<Expr> stack, SetOperation setOperation); @Override LogicalNode visitExcept(PlanContext context, Stack<Expr> stack, SetOperation setOperation); @Override LogicalNode visitIntersect(PlanContext context, Stack<Expr> stack, SetOperation setOperation); LogicalNode visitInsert(PlanContext context, Stack<Expr> stack, Insert expr); @Override LogicalNode visitCreateTable(PlanContext context, Stack<Expr> stack, CreateTable expr); @Override LogicalNode visitDropTable(PlanContext context, Stack<Expr> stack, DropTable dropTable); static boolean checkIfBeEvaluatedAtGroupBy(EvalNode evalNode, GroupbyNode node); static boolean checkIfBeEvaluatedAtJoin(QueryBlock block, EvalNode evalNode, JoinNode node,
                                                 boolean isTopMostJoin); static boolean checkIfBeEvaluatedAtRelation(QueryBlock block, EvalNode evalNode, RelationNode node); static boolean checkIfBeEvaluatedAtThis(EvalNode evalNode, LogicalNode node); static final Column[] ALL; }