Search in sources :

Example 41 with SeqScanPlanNode

use of org.voltdb.plannodes.SeqScanPlanNode in project voltdb by VoltDB.

the class TestPlansDML method checkPredicate.

private void checkPredicate(AbstractPlanNode pn, ExpressionType type) {
    assertTrue(pn instanceof SeqScanPlanNode);
    AbstractExpression e = ((SeqScanPlanNode) pn).getPredicate();
    assertEquals(type, e.getExpressionType());
}
Also used : SeqScanPlanNode(org.voltdb.plannodes.SeqScanPlanNode) AbstractExpression(org.voltdb.expressions.AbstractExpression)

Example 42 with SeqScanPlanNode

use of org.voltdb.plannodes.SeqScanPlanNode in project voltdb by VoltDB.

the class TestPlansDML method checkDMLPlanNodeAndSubqueryExpression.

void checkDMLPlanNodeAndSubqueryExpression(String dmlSQL, ExpressionType filterType) {
    List<AbstractPlanNode> pns = compileToFragments(dmlSQL);
    AbstractPlanNode dmlNode;
    if (pns.size() == 2) {
        dmlNode = pns.get(1).getChild(0);
    } else {
        dmlNode = pns.get(0);
    }
    String dmlType = dmlSQL.substring(0, dmlSQL.indexOf(' ')).trim().toUpperCase();
    if ("UPSERT".equalsIgnoreCase(dmlType)) {
        // UPSERT is INSERT
        dmlType = "INSERT";
    }
    // it could be extended in some way.
    if ((dmlNode instanceof SeqScanPlanNode) && "INSERT".equals(dmlType)) {
        assertNotNull("Expected an insert node.", dmlNode.getInlinePlanNode(PlanNodeType.INSERT));
    } else {
        assertEquals(dmlType, dmlNode.getPlanNodeType().toString());
    }
    PlanNodeType nodeType = dmlNode.getPlanNodeType();
    while (nodeType != PlanNodeType.SEQSCAN && nodeType != PlanNodeType.MATERIALIZE && nodeType != PlanNodeType.INDEXSCAN) {
        dmlNode = dmlNode.getChild(0);
        nodeType = dmlNode.getPlanNodeType();
    }
    assertNotNull(dmlNode);
    // Verify DML Predicate
    if (filterType != null) {
        AbstractExpression predicate = ((AbstractScanPlanNode) dmlNode).getPredicate();
        assertNotNull(predicate);
        assertEquals(filterType, predicate.getExpressionType());
        assertTrue(predicate.hasAnySubexpressionOfClass(SelectSubqueryExpression.class));
    }
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) SeqScanPlanNode(org.voltdb.plannodes.SeqScanPlanNode) PlanNodeType(org.voltdb.types.PlanNodeType) AbstractScanPlanNode(org.voltdb.plannodes.AbstractScanPlanNode) AbstractExpression(org.voltdb.expressions.AbstractExpression) SelectSubqueryExpression(org.voltdb.expressions.SelectSubqueryExpression)

Example 43 with SeqScanPlanNode

use of org.voltdb.plannodes.SeqScanPlanNode in project voltdb by VoltDB.

the class TestPlansInExistsSubQueries method verifyTrivialSchemaLimitOffset.

private void verifyTrivialSchemaLimitOffset(AbstractExpression exists, int limit, int offset) {
    assertNotNull(exists);
    assertEquals(ExpressionType.OPERATOR_EXISTS, exists.getExpressionType());
    AbstractSubqueryExpression se = (AbstractSubqueryExpression) exists.getLeft();
    AbstractPlanNode pn = se.getSubqueryNode();
    assertTrue(pn instanceof SeqScanPlanNode);
    AbstractPlanNode inline = pn.getInlinePlanNode(PlanNodeType.PROJECTION);
    assertNotNull(inline);
    inline = pn.getInlinePlanNode(PlanNodeType.LIMIT);
    assertNotNull(inline);
    assertEquals(limit, ((LimitPlanNode) inline).getLimit());
    assertEquals(offset, ((LimitPlanNode) inline).getOffset());
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) SeqScanPlanNode(org.voltdb.plannodes.SeqScanPlanNode) AbstractSubqueryExpression(org.voltdb.expressions.AbstractSubqueryExpression)

Example 44 with SeqScanPlanNode

use of org.voltdb.plannodes.SeqScanPlanNode in project voltdb by VoltDB.

the class PlannerTestCase method assertReplicatedLeftJoinCoordinator.

/**
     * Assert that a two-fragment plan's coordinator fragment does a left join
     * with a specific replicated table on its outer side.
     **/
protected static void assertReplicatedLeftJoinCoordinator(List<AbstractPlanNode> lpn, String replicatedTable) {
    AbstractPlanNode pn;
    AbstractPlanNode node;
    NestLoopPlanNode nlj;
    SeqScanPlanNode seqScan;
    pn = lpn.get(0);
    assertTopDownTree(pn, PlanNodeType.SEND, PlanNodeType.PROJECTION, PlanNodeType.NESTLOOP, PlanNodeType.SEQSCAN, PlanNodeType.RECEIVE);
    node = followAssertedLeftChain(pn, PlanNodeType.SEND, PlanNodeType.PROJECTION, PlanNodeType.NESTLOOP);
    nlj = (NestLoopPlanNode) node;
    assertEquals(JoinType.LEFT, nlj.getJoinType());
    assertEquals(2, nlj.getChildCount());
    seqScan = (SeqScanPlanNode) nlj.getChild(0);
    assertEquals(replicatedTable, seqScan.getTargetTableName().toUpperCase());
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) SeqScanPlanNode(org.voltdb.plannodes.SeqScanPlanNode) NestLoopPlanNode(org.voltdb.plannodes.NestLoopPlanNode)

Example 45 with SeqScanPlanNode

use of org.voltdb.plannodes.SeqScanPlanNode in project voltdb by VoltDB.

the class TestJoinOrder method testOuterJoinOrder.

public void testOuterJoinOrder() {
    AbstractPlanNode pn = compileSPWithJoinOrder("select * FROM T1 LEFT JOIN T2 ON T1.A = T2.B", "T1, T2");
    AbstractPlanNode n = pn.getChild(0).getChild(0);
    assertTrue(((SeqScanPlanNode) n.getChild(0)).getTargetTableName().equals("T1"));
    assertTrue(((SeqScanPlanNode) n.getChild(1)).getTargetTableName().equals("T2"));
    try {
        compileWithInvalidJoinOrder("select * FROM T1 LEFT JOIN T2 ON T1.A = T2.B", "T2, T1");
        fail();
    } catch (Exception ex) {
        assertTrue("The specified join order is invalid for the given query".equals(ex.getMessage()));
    }
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) SeqScanPlanNode(org.voltdb.plannodes.SeqScanPlanNode)

Aggregations

SeqScanPlanNode (org.voltdb.plannodes.SeqScanPlanNode)49 AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)44 AbstractExpression (org.voltdb.expressions.AbstractExpression)26 NestLoopPlanNode (org.voltdb.plannodes.NestLoopPlanNode)19 IndexScanPlanNode (org.voltdb.plannodes.IndexScanPlanNode)14 ProjectionPlanNode (org.voltdb.plannodes.ProjectionPlanNode)9 NestLoopIndexPlanNode (org.voltdb.plannodes.NestLoopIndexPlanNode)8 AggregatePlanNode (org.voltdb.plannodes.AggregatePlanNode)6 AbstractScanPlanNode (org.voltdb.plannodes.AbstractScanPlanNode)5 OrderByPlanNode (org.voltdb.plannodes.OrderByPlanNode)5 AbstractSubqueryExpression (org.voltdb.expressions.AbstractSubqueryExpression)4 TupleValueExpression (org.voltdb.expressions.TupleValueExpression)4 ReceivePlanNode (org.voltdb.plannodes.ReceivePlanNode)4 SchemaColumn (org.voltdb.plannodes.SchemaColumn)4 ArrayList (java.util.ArrayList)3 Index (org.voltdb.catalog.Index)3 ComparisonExpression (org.voltdb.expressions.ComparisonExpression)3 StmtTableScan (org.voltdb.planner.parseinfo.StmtTableScan)3 LimitPlanNode (org.voltdb.plannodes.LimitPlanNode)3 NodeSchema (org.voltdb.plannodes.NodeSchema)3