Package org.voltdb.plannodes

Examples of org.voltdb.plannodes.IndexScanPlanNode


            this.getColumn(catalog_tbl, "VLR_LOCATION")
        };
       
        AbstractPlanNode root = PlanNodeUtil.getRootPlanNodeForStatement(catalog_stmt, false);
        assertNotNull(root);
        IndexScanPlanNode idx_node = CollectionUtil.first(PlanNodeUtil.getPlanNodes(root, IndexScanPlanNode.class));
        assertNotNull(idx_node);
       
        Collection<Column> columns = PlanNodeUtil.getUpdatedColumnsForPlanNode(catalog_db, idx_node);
        assertNotNull(columns);
//        System.err.print(catalog_stmt.fullName() + ": " + CatalogUtil.debug(columns));
View Full Code Here


        if (nljAccessPlan instanceof IndexScanPlanNode) {
            NestLoopIndexPlanNode nlijNode = new NestLoopIndexPlanNode(m_context, PlanAssembler.getNextPlanNodeId());

            nlijNode.setJoinType(JoinType.INNER);

            IndexScanPlanNode innerNode = (IndexScanPlanNode) nljAccessPlan;

            //
            // Now we have to update the column references used by the inner node
            //
            subPlan.updateOutputColumns(m_db);
            final List<Integer> outputColumns = subPlan.getOutputColumnGUIDs();
            final int offset = outputColumns.size();
            if (innerNode.getPredicate() != null) {
                try {
                    innerNode.setPredicate(ExpressionUtil.clone(innerNode.getPredicate()));
                } catch (Exception e) {
                    e.printStackTrace();
                }
//                System.out.println("Join Tables: ");
//                for (Table t : joinOrder)
//                {
//                  System.out.println("Table Name: " + t.getName());
//                }
                //System.out.println("Node type: " + innerNode.getPlanNodeType() + " offset #: " + offset);
                ExpressionUtil.setAndOffsetColumnIndexes(
                        m_context,
                        innerNode.getPredicate(),
                        offset, joinOrder[0].getTypeName(),
                        outputColumns);
            }

            if (innerNode.getEndExpression() != null) {
                try {
                    innerNode.setEndExpression(ExpressionUtil.clone(innerNode.getEndExpression()));
                } catch (Exception e) {
                    e.printStackTrace();
                }
                ExpressionUtil.setAndOffsetColumnIndexes(
                        m_context, innerNode.getEndExpression(), offset, joinOrder[0].getTypeName(), outputColumns);
            }

            ArrayList<AbstractExpression> searchKeyExpressions = new ArrayList<AbstractExpression>(innerNode.getSearchKeyExpressions());
            innerNode.getSearchKeyExpressions().clear();
            for (int ctr = 0, cnt = searchKeyExpressions.size(); ctr < cnt; ctr++) {
                AbstractExpression expr = null;
                try {
                    expr = ExpressionUtil.clone(searchKeyExpressions.get(ctr));
                } catch (Exception e) {
                    e.printStackTrace();
                    System.exit(-1);
                }
                ExpressionUtil.setColumnIndexes(m_context, expr, outputColumns);
                innerNode.getSearchKeyExpressions().add(expr);
            }

            nlijNode.addInlinePlanNode(nljAccessPlan);

            // combine the tails plan graph with the new head node
View Full Code Here

                "Not unique table/alias: A");
    }

    public void testIndexedSelfJoin() {
        AbstractPlanNode.enableVerboseExplainForDebugging();
        IndexScanPlanNode c;
        AbstractPlanNode apn;
        AbstractPlanNode pn;
        NestLoopIndexPlanNode nlij;
        List<AbstractExpression> searchKeys;
        // SELF JOIN using two different indexes on the same table
        // sometimes with a surviving sort ordering that supports GROUP BY and/or ORDER BY.

        apn = compile("select * FROM R2 A, R2 B WHERE A.A = B.A AND B.C > 1 ORDER BY B.C");
        //* for debug */ System.out.println(apn.toExplainPlanString());
        // Some day, the wasteful projection node will not be here to skip.
        pn = apn.getChild(0).getChild(0);
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        nlij = (NestLoopIndexPlanNode) pn;
        assertNull(nlij.getPreJoinPredicate());
        assertNull(nlij.getJoinPredicate());
        assertNull(nlij.getWherePredicate());
        assertEquals(1, nlij.getChildCount());
        c = (IndexScanPlanNode) nlij.getChild(0);
        assertNull(c.getPredicate());
        assertEquals(IndexLookupType.GT, c.getLookupType());
        searchKeys = c.getSearchKeyExpressions();
        assertEquals(1, searchKeys.size());
        assertTrue(searchKeys.get(0) instanceof ConstantValueExpression);
        c = (IndexScanPlanNode) nlij.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        assertEquals(IndexLookupType.GTE, c.getLookupType());
        assertNull(c.getPredicate());
        searchKeys = c.getSearchKeyExpressions();
        assertEquals(1, searchKeys.size());
        assertTrue(searchKeys.get(0) instanceof TupleValueExpression);

        apn = compile("select * FROM R2 A, R2 B WHERE A.A = B.A AND B.C > 1 ORDER BY B.A, B.C");
        //* for debug */ System.out.println(apn.toExplainPlanString());
        // Some day, the wasteful projection node will not be here to skip.
        pn = apn.getChild(0).getChild(0);
        assertTrue(pn instanceof OrderByPlanNode);
        pn = pn.getChild(0);
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        nlij = (NestLoopIndexPlanNode) pn;
        assertNull(nlij.getPreJoinPredicate());
        assertNull(nlij.getJoinPredicate());
        assertNull(nlij.getWherePredicate());
        assertEquals(1, nlij.getChildCount());
        c = (IndexScanPlanNode) nlij.getChild(0);
        assertNull(c.getPredicate());
        assertEquals(IndexLookupType.GT, c.getLookupType());
        searchKeys = c.getSearchKeyExpressions();
        assertEquals(1, searchKeys.size());
        assertTrue(searchKeys.get(0) instanceof ConstantValueExpression);
        c = (IndexScanPlanNode) nlij.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        assertEquals(IndexLookupType.GTE, c.getLookupType());
        assertNull(c.getPredicate());
        searchKeys = c.getSearchKeyExpressions();
        assertEquals(1, searchKeys.size());
        assertTrue(searchKeys.get(0) instanceof TupleValueExpression);

        apn = compile("select * FROM R2 A, R2 B WHERE A.A = B.A AND B.A > 1 ORDER BY B.A, B.C");
        //* for debug */ System.out.println(apn.toExplainPlanString());
        // Some day, the wasteful projection node will not be here to skip.
        pn = apn.getChild(0).getChild(0);
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        nlij = (NestLoopIndexPlanNode) pn;
        assertNull(nlij.getPreJoinPredicate());
        assertNull(nlij.getJoinPredicate());
        assertNull(nlij.getWherePredicate());
        assertEquals(1, nlij.getChildCount());
        assertTrue(nlij.getChild(0) instanceof IndexScanPlanNode);
        c = (IndexScanPlanNode) nlij.getChild(0);
        assertEquals(IndexLookupType.GT, c.getLookupType());
        searchKeys = c.getSearchKeyExpressions();
        assertEquals(1, searchKeys.size());
        assertTrue(searchKeys.get(0) instanceof ConstantValueExpression);
        c = (IndexScanPlanNode) nlij.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        assertEquals(IndexLookupType.GTE, c.getLookupType());
        assertNull(c.getPredicate());
        searchKeys = c.getSearchKeyExpressions();
        assertEquals(1, searchKeys.size());
        assertTrue(searchKeys.get(0) instanceof TupleValueExpression);

        apn = compile("select B.C, MAX(A.C) FROM R2 A, R2 B WHERE A.A = B.A AND B.C > 1 GROUP BY B.C ORDER BY B.C");
        //* for debug */ System.out.println(apn.toExplainPlanString());
        // Some day, the wasteful projection node will not be here to skip.
        pn = apn.getChild(0);
        assertNotNull(AggregatePlanNode.getInlineAggregationNode(pn));
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        nlij = (NestLoopIndexPlanNode) pn;
        assertNull(nlij.getPreJoinPredicate());
        assertNull(nlij.getJoinPredicate());
        assertNull(nlij.getWherePredicate());
        assertEquals(1, nlij.getChildCount());
        c = (IndexScanPlanNode) nlij.getChild(0);
        assertNull(c.getPredicate());
        assertEquals(IndexLookupType.GT, c.getLookupType());
        searchKeys = c.getSearchKeyExpressions();
        assertEquals(1, searchKeys.size());
        assertTrue(searchKeys.get(0) instanceof ConstantValueExpression);
        c = (IndexScanPlanNode) nlij.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        assertEquals(IndexLookupType.GTE, c.getLookupType());
        assertNull(c.getPredicate());
        searchKeys = c.getSearchKeyExpressions();
        assertEquals(1, searchKeys.size());
        assertTrue(searchKeys.get(0) instanceof TupleValueExpression);

        apn = compile("select B.C, B.A FROM R2 A, R2 B WHERE A.A = B.A AND B.C > 1 GROUP BY B.A, B.C ORDER BY B.A, B.C");
        //* for debug */ System.out.println(apn.toExplainPlanString());
        // Some day, the wasteful projection node will not be here to skip.
        pn = apn.getChild(0).getChild(0);
        assertTrue(pn instanceof OrderByPlanNode);
        pn = pn.getChild(0);
        assertNotNull(AggregatePlanNode.getInlineAggregationNode(pn));
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        nlij = (NestLoopIndexPlanNode) pn;
        assertNull(nlij.getPreJoinPredicate());
        assertNull(nlij.getJoinPredicate());
        assertNull(nlij.getWherePredicate());
        assertEquals(1, nlij.getChildCount());
        c = (IndexScanPlanNode) nlij.getChild(0);
        assertNull(c.getPredicate());
        assertEquals(IndexLookupType.GT, c.getLookupType());
        searchKeys = c.getSearchKeyExpressions();
        assertEquals(1, searchKeys.size());
        assertTrue(searchKeys.get(0) instanceof ConstantValueExpression);
        c = (IndexScanPlanNode) nlij.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        assertEquals(IndexLookupType.GTE, c.getLookupType());
        assertNull(c.getPredicate());
        searchKeys = c.getSearchKeyExpressions();
        assertEquals(1, searchKeys.size());
        assertTrue(searchKeys.get(0) instanceof TupleValueExpression);

        apn = compile("select B.C, B.A FROM R2 A, R2 B WHERE A.A = B.A AND B.A > 1 GROUP BY B.A, B.C ORDER BY B.A, B.C");
        //* for debug */ System.out.println(apn.toExplainPlanString());
        // Some day, the wasteful projection node will not be here to skip.
        pn = apn.getChild(0);
        assertNotNull(AggregatePlanNode.getInlineAggregationNode(pn));
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        nlij = (NestLoopIndexPlanNode) pn;
        assertNull(nlij.getPreJoinPredicate());
        assertNull(nlij.getJoinPredicate());
        assertNull(nlij.getWherePredicate());
        assertEquals(1, nlij.getChildCount());
        assertTrue(nlij.getChild(0) instanceof IndexScanPlanNode);
        c = (IndexScanPlanNode) nlij.getChild(0);
        assertEquals(IndexLookupType.GT, c.getLookupType());
        searchKeys = c.getSearchKeyExpressions();
        assertEquals(1, searchKeys.size());
        assertTrue(searchKeys.get(0) instanceof ConstantValueExpression);
        c = (IndexScanPlanNode) nlij.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        assertEquals(IndexLookupType.GTE, c.getLookupType());
        assertNull(c.getPredicate());
        searchKeys = c.getSearchKeyExpressions();
        assertEquals(1, searchKeys.size());
        assertTrue(searchKeys.get(0) instanceof TupleValueExpression);

        // Here's a case that can't be optimized because it purposely uses the "wrong" alias
        // in the GROUP BY and ORDER BY.
        apn = compile("select B.C, B.A FROM R2 A, R2 B WHERE A.A = B.A AND B.C > 1 GROUP BY B.A, A.C ORDER BY B.A, A.C");
        //* for debug */ System.out.println(apn.toExplainPlanString());
        // Some day, the wasteful projection node will not be here to skip.
        pn = apn.getChild(0).getChild(0);
        assertTrue(pn instanceof OrderByPlanNode);
        pn = pn.getChild(0);
        assertNotNull(AggregatePlanNode.getInlineAggregationNode(pn));
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        nlij = (NestLoopIndexPlanNode) pn;
        assertNull(nlij.getPreJoinPredicate());
        assertNull(nlij.getJoinPredicate());
        assertNull(nlij.getWherePredicate());
        assertEquals(1, nlij.getChildCount());
        c = (IndexScanPlanNode) nlij.getChild(0);
        assertNull(c.getPredicate());
        assertEquals(IndexLookupType.GT, c.getLookupType());
        searchKeys = c.getSearchKeyExpressions();
        assertEquals(1, searchKeys.size());
        assertTrue(searchKeys.get(0) instanceof ConstantValueExpression);
        c = (IndexScanPlanNode) nlij.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        assertEquals(IndexLookupType.GTE, c.getLookupType());
        assertNull(c.getPredicate());
        searchKeys = c.getSearchKeyExpressions();
        assertEquals(1, searchKeys.size());
        assertTrue(searchKeys.get(0) instanceof TupleValueExpression);

        // This variant shows that the GROUP BY can be a permutation of the sort order
        // without messing up the optimization
        apn = compile("select B.C, B.A FROM R2 A, R2 B WHERE A.A = B.A AND B.A > 1 GROUP BY B.C, B.A ORDER BY B.A, B.C");
        //* for debug */ System.out.println(apn.toExplainPlanString());
        // Some day, the wasteful projection node will not be here to skip.
        pn = apn.getChild(0);
        assertNotNull(AggregatePlanNode.getInlineAggregationNode(pn));
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        nlij = (NestLoopIndexPlanNode) pn;
        assertNull(nlij.getPreJoinPredicate());
        assertNull(nlij.getJoinPredicate());
        assertNull(nlij.getWherePredicate());
        assertEquals(1, nlij.getChildCount());
        assertTrue(nlij.getChild(0) instanceof IndexScanPlanNode);
        c = (IndexScanPlanNode) nlij.getChild(0);
        assertEquals(IndexLookupType.GT, c.getLookupType());
        searchKeys = c.getSearchKeyExpressions();
        assertEquals(1, searchKeys.size());
        assertTrue(searchKeys.get(0) instanceof ConstantValueExpression);
        c = (IndexScanPlanNode) nlij.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        assertEquals(IndexLookupType.GTE, c.getLookupType());
        assertNull(c.getPredicate());
        searchKeys = c.getSearchKeyExpressions();
        assertEquals(1, searchKeys.size());
        assertTrue(searchKeys.get(0) instanceof TupleValueExpression);
   }
View Full Code Here

        assertNull(((IndexScanPlanNode) n).getPredicate());

        pn = compile("select * FROM R3 WHERE R3.A > 0 and R3.A < 5 and R3.C = 4");
        n = pn.getChild(0);
        assertTrue(n instanceof IndexScanPlanNode);
        IndexScanPlanNode indexScan = (IndexScanPlanNode) n;
        AbstractExpression p = indexScan.getPredicate();
        assertEquals(ExpressionType.COMPARE_EQUAL, p.getExpressionType());
        p = indexScan.getEndExpression();
        assertEquals(ExpressionType.COMPARE_LESSTHAN, p.getExpressionType());
        assertEquals(IndexLookupType.GT, indexScan.getLookupType());

        pn = compile("select * FROM R3, R2 WHERE R3.A = R2.A AND R3.C > 0 and R2.C >= 5");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopIndexPlanNode);
        assertNull(((NestLoopIndexPlanNode) n).getJoinPredicate());
        indexScan = (IndexScanPlanNode)n.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        assertEquals(IndexLookupType.EQ, indexScan.getLookupType());
        assertEquals(ExpressionType.COMPARE_EQUAL, indexScan.getEndExpression().getExpressionType());
        assertEquals(ExpressionType.COMPARE_GREATERTHAN, indexScan.getPredicate().getExpressionType());
        AbstractPlanNode seqScan = n.getChild(0);
        assertTrue(seqScan instanceof SeqScanPlanNode);
        assertEquals(ExpressionType.COMPARE_GREATERTHANOREQUALTO, ((SeqScanPlanNode)seqScan).getPredicate().getExpressionType());

        pn = compile("select * FROM R3 JOIN R2 ON R3.A = R2.A WHERE R3.C > 0 and R2.C >= 5");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopIndexPlanNode);
        assertNull(((NestLoopIndexPlanNode) n).getJoinPredicate());
        indexScan = (IndexScanPlanNode)n.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        assertEquals(IndexLookupType.EQ, indexScan.getLookupType());
        assertEquals(ExpressionType.COMPARE_EQUAL, indexScan.getEndExpression().getExpressionType());
        seqScan = n.getChild(0);
        assertTrue(seqScan instanceof SeqScanPlanNode);
        assertEquals(ExpressionType.COMPARE_GREATERTHANOREQUALTO, ((SeqScanPlanNode)seqScan).getPredicate().getExpressionType());

        pn = compile("select * FROM R3 JOIN R2 USING(A) WHERE R3.C > 0 and R2.C >= 5");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopIndexPlanNode);
        assertNull(((NestLoopIndexPlanNode) n).getJoinPredicate());
        indexScan = (IndexScanPlanNode)n.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        assertEquals(IndexLookupType.EQ, indexScan.getLookupType());
        assertEquals(ExpressionType.COMPARE_EQUAL, indexScan.getEndExpression().getExpressionType());
        seqScan = n.getChild(0);
        assertTrue(seqScan instanceof SeqScanPlanNode);
        assertEquals(ExpressionType.COMPARE_GREATERTHANOREQUALTO, ((SeqScanPlanNode)seqScan).getPredicate().getExpressionType());

        pn = compile("select * FROM R3 JOIN R2 ON R3.A = R2.A JOIN R1 ON R2.A = R1.A WHERE R3.C > 0 and R2.C >= 5");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        p = ((NestLoopPlanNode) n).getJoinPredicate();
        assertEquals(ExpressionType.COMPARE_EQUAL, p.getExpressionType());
        assertEquals(ExpressionType.VALUE_TUPLE, p.getLeft().getExpressionType());
        assertEquals(ExpressionType.VALUE_TUPLE, p.getRight().getExpressionType());
        seqScan = n.getChild(1);
        assertTrue(seqScan instanceof SeqScanPlanNode);
        n = n.getChild(0);
        assertTrue(n instanceof NestLoopIndexPlanNode);
        NestLoopIndexPlanNode nlij = (NestLoopIndexPlanNode) n;
        indexScan = (IndexScanPlanNode)nlij.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        assertEquals(IndexLookupType.EQ, indexScan.getLookupType());
        assertEquals(ExpressionType.COMPARE_EQUAL, indexScan.getEndExpression().getExpressionType());
        seqScan = nlij.getChild(0);
        assertTrue(seqScan instanceof SeqScanPlanNode);
        assertEquals(ExpressionType.COMPARE_GREATERTHANOREQUALTO, ((SeqScanPlanNode)seqScan).getPredicate().getExpressionType());

    }
View Full Code Here

        assertTrue(n instanceof NestLoopPlanNode);
        nl = (NestLoopPlanNode) n;
        assertEquals(JoinType.LEFT, nl.getJoinType());
        AbstractPlanNode outerScan = n.getChild(0);
        assertTrue(outerScan instanceof IndexScanPlanNode);
        IndexScanPlanNode indexScan = (IndexScanPlanNode) outerScan;
        assertEquals(IndexLookupType.GT, indexScan.getLookupType());
        assertNotNull(indexScan.getPredicate());
        assertEquals(ExpressionType.COMPARE_LESSTHAN, indexScan.getPredicate().getExpressionType());

        // R3.C = R2.C Inner-Outer non-index join Expr. NLJ predicate.
        // R3.A > 3 Index null rejecting inner where expr pushed down to IndexScanPlanNode
        // NLJ is simplified to be INNER
        pn = compile("select * FROM R2 LEFT JOIN R3 ON R3.C = R2.C WHERE R3.A > 3");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nl = (NestLoopPlanNode) n;
        assertEquals(JoinType.INNER, nl.getJoinType());
        outerScan = n.getChild(1);
        assertTrue(outerScan instanceof IndexScanPlanNode);
        indexScan = (IndexScanPlanNode) outerScan;
        assertEquals(IndexLookupType.GT, indexScan.getLookupType());
        assertNull(indexScan.getPredicate());

        pn = compile("select * FROM R2 LEFT JOIN R3 ON R3.A = R2.C WHERE R3.A > 3");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopIndexPlanNode);
        NestLoopIndexPlanNode nli = (NestLoopIndexPlanNode) n;
View Full Code Here

        assertNotNull(nlij.getPreJoinPredicate());
        AbstractExpression p = nlij.getPreJoinPredicate();
        assertEquals(ExpressionType.COMPARE_LESSTHAN, p.getExpressionType());
        assertNull(nlij.getJoinPredicate());
        assertNull(nlij.getWherePredicate());
        IndexScanPlanNode indexScan = (IndexScanPlanNode)n.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        assertEquals(IndexLookupType.EQ, indexScan.getLookupType());
        assertEquals(ExpressionType.COMPARE_EQUAL, indexScan.getEndExpression().getExpressionType());
        assertEquals(ExpressionType.COMPARE_GREATERTHAN, indexScan.getPredicate().getExpressionType());
        AbstractPlanNode c1 = n.getChild(0);
        assertTrue(c1 instanceof SeqScanPlanNode);
        assertNull(((SeqScanPlanNode)c1).getPredicate());

        // R1.C = R3.A Inner-Outer non-index join Expr. NLJ/IndexScan
        // R3.A > 0 Inner index Join Expr is pushed down to the inner IndexScan node as an index
        // R3.C != 0 Non-index Inner Join Expression is pushed down to the inner IndexScan node as a predicate
        // R2.A < 6 Outer Join Expr is a pre-join predicate for NLJ
        pn = compile("select * FROM R2 LEFT JOIN R3 ON R3.C = R2.A AND R3.A > 0 AND R3.C != 0 AND R2.A < 6");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        NestLoopPlanNode nlj = (NestLoopPlanNode) n;
        assertEquals(JoinType.LEFT, nlj.getJoinType());
        assertNotNull(nlj.getPreJoinPredicate());
        p = nlj.getPreJoinPredicate();
        assertEquals(ExpressionType.COMPARE_LESSTHAN, p.getExpressionType());
        assertNotNull(nlj.getJoinPredicate());
        assertEquals(ExpressionType.COMPARE_EQUAL, nlj.getJoinPredicate().getExpressionType());
        assertNull(nlj.getWherePredicate());
        c1 = n.getChild(0);
        assertTrue(c1 instanceof SeqScanPlanNode);
        assertNull(((SeqScanPlanNode)c1).getPredicate());
        AbstractPlanNode c2 = n.getChild(1);
        assertTrue(c2 instanceof IndexScanPlanNode);
        indexScan = (IndexScanPlanNode) c2;
        assertEquals(IndexLookupType.GT, indexScan.getLookupType());
        assertNotNull(indexScan.getPredicate());
        assertEquals(ExpressionType.COMPARE_NOTEQUAL, indexScan.getPredicate().getExpressionType());

        // R2.A = R3.A Inner-Outer index join Expr. NLIJ/Inlined IndexScan
        // R3.A IS NULL Inner where expr - part of the NLIJ where predicate
        // R2.A < 6 OR R3.C IS NULL Inner-Outer where expr - part of the NLIJ where predicate
        // R2.A > 3 Outer where expr - pushed down to the outer node
        pn = compile("select * FROM R2 LEFT JOIN R3 ON R3.A = R2.A WHERE R3.A IS NULL AND R2.A > 3 AND (R2.A < 6 OR R3.C IS NULL)");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopIndexPlanNode);
        assertEquals(((NestLoopIndexPlanNode) n).getJoinType(), JoinType.LEFT);
        assertNull(((NestLoopIndexPlanNode) n).getPreJoinPredicate());
        assertNull(((NestLoopIndexPlanNode) n).getJoinPredicate());
        assertNotNull(((NestLoopIndexPlanNode) n).getWherePredicate());
        AbstractExpression w = ((NestLoopIndexPlanNode) n).getWherePredicate();
        assertEquals(ExpressionType.CONJUNCTION_AND, w.getExpressionType());
        assertEquals(ExpressionType.OPERATOR_IS_NULL, w.getRight().getExpressionType());
        assertEquals(ExpressionType.CONJUNCTION_OR, w.getLeft().getExpressionType());
        indexScan = (IndexScanPlanNode)n.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        assertEquals(IndexLookupType.EQ, indexScan.getLookupType());
        assertEquals(ExpressionType.COMPARE_EQUAL, indexScan.getEndExpression().getExpressionType());
        c1 = n.getChild(0);
        assertTrue(c1 instanceof SeqScanPlanNode);
        assertEquals(ExpressionType.COMPARE_GREATERTHAN, ((SeqScanPlanNode)c1).getPredicate().getExpressionType());

    }
View Full Code Here

        assertTrue(c instanceof SeqScanPlanNode);
        c = n.getChild(1);
        assertTrue(c instanceof ReceivePlanNode);
        n = lpn.get(1).getChild(0);
        assertTrue(n instanceof IndexScanPlanNode);
        IndexScanPlanNode in = (IndexScanPlanNode) n;
        assertEquals(IndexLookupType.LT, in.getLookupType());

        assertNotNull(in.getPredicate());
        assertEquals(ExpressionType.CONJUNCTION_AND, in.getPredicate().getExpressionType());
        assertEquals(ExpressionType.COMPARE_GREATERTHAN, in.getPredicate().getLeft().getExpressionType());
        assertEquals(ExpressionType.OPERATOR_NOT, in.getPredicate().getRight().getExpressionType());

        // Distributed inner  and outer tables -NLIJ/inlined IndexScan
        lpn = compileToFragments("select *  FROM P2 RIGHT JOIN P3 ON P3.A = P2.A AND P2.A < 0 WHERE P2.A IS NULL");
        assertEquals(2, lpn.size());
        n = lpn.get(1).getChild(0);
        assertTrue(n instanceof NestLoopIndexPlanNode);
        assertEquals(JoinType.LEFT, ((NestLoopIndexPlanNode) n).getJoinType());
        assertNull(((NestLoopIndexPlanNode) n).getJoinPredicate());
        assertNotNull(((NestLoopIndexPlanNode) n).getWherePredicate());
        AbstractExpression w = ((NestLoopIndexPlanNode) n).getWherePredicate();
        assertEquals(ExpressionType.OPERATOR_IS_NULL, w.getExpressionType());
        IndexScanPlanNode indexScan = (IndexScanPlanNode)n.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        assertEquals(IndexLookupType.EQ, indexScan.getLookupType());
        assertEquals(ExpressionType.COMPARE_EQUAL, indexScan.getEndExpression().getExpressionType());
        w = indexScan.getPredicate();
        assertNotNull(w);
        assertEquals(ExpressionType.COMPARE_LESSTHAN, w.getExpressionType());
    }
View Full Code Here

        AbstractPlanNode pn = compile("select id from a, t where a.id < (t.a + ?);");
        pn = pn.getChild(0);
        pn = pn.getChild(0);
//        System.out.println("DEBUG: " + pn.toExplainPlanString());
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        IndexScanPlanNode indexScan = (IndexScanPlanNode)pn.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        assertEquals(IndexLookupType.LT, indexScan.getLookupType());
        assertTrue(indexScan.toJSONString().contains("\"TARGET_INDEX_NAME\":\"" +
                HSQLInterface.AUTO_GEN_CONSTRAINT_WRAPPER_PREFIX + "ID"));
        pn = pn.getChild(0);
        assertTrue(pn instanceof SeqScanPlanNode);
//        System.out.println("DEBUG: " + pn.toJSONString());
        assertTrue(pn.toJSONString().contains("\"TARGET_TABLE_NAME\":\"T\""));
View Full Code Here

    }

    public void testFixedPlanWithExpressionIndexAndAlias()
    {
        AbstractPlanNode pn;
        IndexScanPlanNode ispn;
        String json;
        pn = compile(
                "select * from l aliased where  b = ? and DECODE(a, null, 0, a) = 0 and id = ?;");
        // System.out.println("DEBUG: " + pn.toExplainPlanString());
        pn = pn.getChild(0);
        assertTrue(pn instanceof IndexScanPlanNode);
        json = pn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"DECODE_IDX3\""));
        ispn = (IndexScanPlanNode)pn;
        assertEquals(3, ispn.getSearchKeyExpressions().size());

        pn = compile(
                "select * from l aliased, l where l.b = ? and DECODE(l.a, null, 0, l.a) = 0 and l.id = ? and l.lname = aliased.lname;");
        //* to debug */ System.out.println("DEBUG: " + pn.toExplainPlanString());
        // Skip the Send, Projection, and NestLoop plan nodes.
        pn = pn.getChild(0).getChild(0);
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        ispn = (IndexScanPlanNode)pn.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        json = ispn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"IDX_A\""));
        pn = pn.getChild(0);
        assertTrue(pn instanceof IndexScanPlanNode);
        json = pn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"DECODE_IDX3\""));
        ispn = (IndexScanPlanNode)pn;
        assertEquals(3, ispn.getSearchKeyExpressions().size());

        pn = compile(
                "select * from l x, l where x.b = ? and DECODE(x.a, null, 0, x.a) = 0 and x.id = ? and l.lname = x.lname;");
        //* to debug */ System.out.println("DEBUG: " + pn.toExplainPlanString());
        // Skip the Send, Projection, and NestLoop plan nodes.
        pn = pn.getChild(0).getChild(0).getChild(0);
        assertTrue(pn instanceof IndexScanPlanNode);
        json = pn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"DECODE_IDX3\""));
        ispn = (IndexScanPlanNode)pn;
        assertEquals(3, ispn.getSearchKeyExpressions().size());

        pn = compile(
                "select * from l x, l where x.b = ? and DECODE(x.a, null, 0, x.a) = 0 and x.id = ? and l.lname = x.lname;");
        //* to debug */ System.out.println("DEBUG: " + pn.toExplainPlanString());
        // Skip the Send, Projection, and NestLoop plan nodes.
        pn = pn.getChild(0).getChild(0).getChild(0);
        assertTrue(pn instanceof IndexScanPlanNode);
        json = pn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"DECODE_IDX3\""));
        ispn = (IndexScanPlanNode)pn;
        assertEquals(3, ispn.getSearchKeyExpressions().size());

        pn = compile(
                "select * from l x, l where l.b = ? and DECODE(x.a, null, 0, x.a) = 0 and x.id = ? and l.lname = x.lname;");
        //*/ to debug */ System.out.println("DEBUG: " + pn.toExplainPlanString());
        // Skip the Send, Projection, and NestLoop plan nodes.
        pn = pn.getChild(0).getChild(0);
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        ispn = (IndexScanPlanNode)pn.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        json = ispn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"" +
                HSQLInterface.AUTO_GEN_CONSTRAINT_WRAPPER_PREFIX + "PK_LOG"));
        pn = pn.getChild(0);
        assertTrue(pn instanceof IndexScanPlanNode);
        json = pn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"DECODE_IDX3\""));
        ispn = (IndexScanPlanNode)pn;
        assertEquals(1, ispn.getSearchKeyExpressions().size());

        pn = compile(
                "select * from l x, l where l.b = ? and DECODE(x.a, null, 0, x.a) = 0 and l.id = ? and l.lname = x.lname;");
        //*/ to debug */ System.out.println("DEBUG: " + pn.toExplainPlanString());
        // Skip the Send, and Projection plan nodes.
        pn = pn.getChild(0).getChild(0);
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        ispn = (IndexScanPlanNode)pn.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        json = ispn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"IDX_A\""));
        pn = pn.getChild(0);
        assertTrue(pn instanceof IndexScanPlanNode);
        json = pn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"DECODE_IDX3\""));
        ispn = (IndexScanPlanNode)pn;
        assertEquals(1, ispn.getSearchKeyExpressions().size());

        pn = compile(
                "select * from l x, l where x.b = ? and DECODE(l.a, null, 0, l.a) = 0 and x.id = ? and l.lname = x.lname;");
        //*/ to debug */ System.out.println("DEBUG: " + pn.toExplainPlanString());
        // Skip the Send and Projection plan nodes.
        pn = pn.getChild(0).getChild(0);
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        ispn = (IndexScanPlanNode)pn.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        json = ispn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"IDX_A\""));
        pn = pn.getChild(0);
        assertTrue(pn instanceof IndexScanPlanNode);
        json = pn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"DECODE_IDX3\""));
        ispn = (IndexScanPlanNode)pn;
        assertEquals(1, ispn.getSearchKeyExpressions().size());

        pn = compile(
                "select * from l x, l where l.b = ? and DECODE(x.a, null, 0, x.a) = 0 and l.id = ? and l.lname = x.lname;");
        System.out.println("DEBUG: " + pn.toExplainPlanString());
        // Skip the Send and Projection plan nodes.
        pn = pn.getChild(0).getChild(0);
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        ispn = (IndexScanPlanNode)pn.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        json = ispn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"IDX_A\""));
        pn = pn.getChild(0);
        assertTrue(pn instanceof IndexScanPlanNode);
        json = pn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"DECODE_IDX3\""));
        ispn = (IndexScanPlanNode)pn;
        assertEquals(1, ispn.getSearchKeyExpressions().size());

        pn = compile(
                "select * from l x, l where x.b = ? and DECODE(l.a, null, 0, x.a) = 0 and x.id = ? and l.lname = x.lname;");
        //*/ to debug */ System.out.println("DEBUG: " + pn.toExplainPlanString());
        // Skip the Send and Projection plan nodes.
        pn = pn.getChild(0).getChild(0);
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        ispn = (IndexScanPlanNode)pn.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        json = ispn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"IDX_A\""));
        pn = pn.getChild(0);
        assertTrue(pn instanceof IndexScanPlanNode);
        json = pn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"DECODE_IDX3\""));
        ispn = (IndexScanPlanNode)pn;
        assertEquals(1, ispn.getSearchKeyExpressions().size());

        pn = compile(
                "select * from l x, l where l.b = ? and DECODE(x.a, null, 0, l.a) = 0 and l.id = ? and l.lname = x.lname;");
        System.out.println("DEBUG: " + pn.toExplainPlanString());
        // Skip the Send and Projection plan nodes.
        pn = pn.getChild(0).getChild(0);
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        ispn = (IndexScanPlanNode)pn.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        json = ispn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"IDX_A\""));
        pn = pn.getChild(0);
        assertTrue(pn instanceof IndexScanPlanNode);
        json = pn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"DECODE_IDX3\""));
        ispn = (IndexScanPlanNode)pn;
        assertEquals(1, ispn.getSearchKeyExpressions().size());

        pn = compile(
                "select * from l x, l where x.b = ? and DECODE(l.a, null, 0, x.a) = 0 and x.id = ? and l.lname = x.lname;");
        //*/ to debug */ System.out.println("DEBUG: " + pn.toExplainPlanString());
        // Skip the Send and Projection plan nodes.
        pn = pn.getChild(0).getChild(0);
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        ispn = (IndexScanPlanNode)pn.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        json = ispn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"IDX_A\""));
        pn = pn.getChild(0);
        assertTrue(pn instanceof IndexScanPlanNode);
        json = pn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"DECODE_IDX3\""));
        ispn = (IndexScanPlanNode)pn;
        assertEquals(1, ispn.getSearchKeyExpressions().size());

        pn = compile(
                "select * from l x, l where l.b = ? and DECODE(x.a, null, 0, l.a) = 0 and x.id = ? and l.lname = x.lname;");
        System.out.println("DEBUG: " + pn.toExplainPlanString());
        // Skip the Send and Projection plan nodes.
        pn = pn.getChild(0).getChild(0);
        assertTrue(pn instanceof NestLoopIndexPlanNode);
        ispn = (IndexScanPlanNode)pn.getInlinePlanNode(PlanNodeType.INDEXSCAN);
        json = ispn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"" +
                HSQLInterface.AUTO_GEN_CONSTRAINT_WRAPPER_PREFIX + "PK_LOG"));
        pn = pn.getChild(0);
        assertTrue(pn instanceof IndexScanPlanNode);
        json = pn.toJSONString();
        assertTrue(json.contains("\"TARGET_INDEX_NAME\":\"DECODE_IDX3\""));
        ispn = (IndexScanPlanNode)pn;
        assertEquals(1, ispn.getSearchKeyExpressions().size());
    }
View Full Code Here

        pn = pn.getChild(0);
        if (pn != null) {
            System.out.println(pn.toJSONString());
        }
        assertTrue(pn instanceof IndexScanPlanNode);
        IndexScanPlanNode ispn = (IndexScanPlanNode)pn;
        assertEquals("COVER2_TREE", ispn.getTargetIndexName());
        assertEquals(IndexLookupType.LT, ispn.getLookupType());
        assertEquals(2, ispn.getSearchKeyExpressions().size());
    }
View Full Code Here

TOP

Related Classes of org.voltdb.plannodes.IndexScanPlanNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.