Search in sources :

Example 11 with RelationalPlan

use of org.teiid.query.processor.relational.RelationalPlan in project teiid by teiid.

the class TestProcedurePlanner method testLoopInstructionTransaction.

@Test
public void testLoopInstructionTransaction() throws Exception {
    // create a dummy instruction that may need a transaction to create the loop
    LoopInstruction loop = new LoopInstruction(new Program(false) {

        @Override
        public Boolean requiresTransaction(boolean transactionalReads) {
            return null;
        }
    }, "x", new RelationalPlan(new RelationalNode(1) {

        @Override
        protected TupleBatch nextBatchDirect() throws BlockedException, TeiidComponentException, TeiidProcessingException {
            return null;
        }

        @Override
        public Object clone() {
            return null;
        }
    }), "y");
    assertNull(loop.requiresTransaction(true));
}
Also used : LoopInstruction(org.teiid.query.processor.proc.LoopInstruction) RelationalNode(org.teiid.query.processor.relational.RelationalNode) Program(org.teiid.query.processor.proc.Program) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) Test(org.junit.Test)

Example 12 with RelationalPlan

use of org.teiid.query.processor.relational.RelationalPlan in project teiid by teiid.

the class TestTextTable method testTextTableJoin1.

@Test
public void testTextTableJoin1() throws Exception {
    String sql = "select e1, e2 from texttable('a' COLUMNS col string) x, pm1.g1 where col = e1";
    List<?>[] expected = new List<?>[] { Arrays.asList("a", 0), Arrays.asList("a", 3), Arrays.asList("a", 0) };
    FakeDataManager dataManager = new FakeDataManager();
    sampleData1(dataManager);
    RelationalPlan plan = (RelationalPlan) helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached());
    helpProcess(plan, createCommandContext(), dataManager, expected);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) Test(org.junit.Test)

Example 13 with RelationalPlan

use of org.teiid.query.processor.relational.RelationalPlan in project teiid by teiid.

the class TestRelationalPlan method testNoRowsFirstBatch.

public void testNoRowsFirstBatch() throws Exception {
    RelationalNode node = new FakeRelationalNode(0, new List[0]);
    RelationalPlan plan = new RelationalPlan(node);
    TupleBatch batch = plan.nextBatch();
    // $NON-NLS-1$
    assertTrue("Did not get terminator batch", batch.getTerminationFlag());
}
Also used : RelationalNode(org.teiid.query.processor.relational.RelationalNode) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) TupleBatch(org.teiid.common.buffer.TupleBatch)

Example 14 with RelationalPlan

use of org.teiid.query.processor.relational.RelationalPlan in project teiid by teiid.

the class TestDependentJoins method testLargeSetInDepAccessWithAccessPattern.

@Test
public void testLargeSetInDepAccessWithAccessPattern() {
    // $NON-NLS-1$
    String sql = "SELECT a.e1, b.e1, b.e2 FROM pm4.g1 a INNER JOIN pm1.g1 b ON a.e1=b.e1 AND a.e2 = b.e2";
    // Create expected results
    List[] expected = new List[] { Arrays.asList(new Object[] { "aa ", "aa ", // $NON-NLS-1$ //$NON-NLS-2$
    0 }), Arrays.asList(new Object[] { "bb   ", "bb   ", // $NON-NLS-1$ //$NON-NLS-2$
    1 }), Arrays.asList(new Object[] { "cc  ", "cc  ", // $NON-NLS-1$ //$NON-NLS-2$
    2 }) };
    // Plan query
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities depcaps = new BasicSourceCapabilities();
    depcaps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
    depcaps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, 1);
    depcaps.setCapabilitySupport(Capability.CRITERIA_IN, true);
    BasicSourceCapabilities caps = new BasicSourceCapabilities();
    caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
    caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm4", depcaps);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    QueryMetadataInterface fakeMetadata = RealMetadataFactory.example1Cached();
    Command command = TestProcessor.helpParse(sql);
    ProcessorPlan plan = TestProcessor.helpGetPlan(command, fakeMetadata, capFinder);
    // Verify a dependent join (not merge join) was used
    assertTrue(plan instanceof RelationalPlan);
    RelationalPlan relationalPlan = (RelationalPlan) plan;
    RelationalNode project = relationalPlan.getRootNode();
    RelationalNode join = project.getChildren()[0];
    // $NON-NLS-1$
    assertTrue("Expected instance of JoinNode (for dep join) but got " + join.getClass(), join instanceof JoinNode);
    // Construct data manager with data
    FakeDataManager dataManager = new FakeDataManager();
    TestProcessor.sampleData2b(dataManager, fakeMetadata);
    // Run query
    TestProcessor.helpProcess(plan, dataManager, expected);
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) RelationalNode(org.teiid.query.processor.relational.RelationalNode) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) Command(org.teiid.query.sql.lang.Command) JoinNode(org.teiid.query.processor.relational.JoinNode) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) Test(org.junit.Test)

Example 15 with RelationalPlan

use of org.teiid.query.processor.relational.RelationalPlan in project teiid by teiid.

the class TestProcedureRelational method helpTestProcRelational.

private void helpTestProcRelational(String userQuery, String inputCriteria, String atomicQuery) {
    ProcessorPlan plan = TestOptimizer.helpPlan(userQuery, RealMetadataFactory.example1Cached(), new String[] {});
    RelationalPlan rplan = (RelationalPlan) plan;
    RelationalNode root = rplan.getRootNode();
    while (root.getChildren() != null) {
        root = root.getChildren()[0];
        if (root instanceof DependentProcedureExecutionNode) {
            break;
        }
    }
    DependentProcedureExecutionNode dep = (DependentProcedureExecutionNode) root;
    assertEquals(inputCriteria, dep.getInputCriteria().toString());
    ProcedurePlan pp = (ProcedurePlan) dep.getProcessorPlan();
    CreateCursorResultSetInstruction ccrsi = (CreateCursorResultSetInstruction) pp.getOriginalProgram().getInstructionAt(0);
    plan = ccrsi.getCommand();
    TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
    TestOptimizer.checkAtomicQueries(new String[] { atomicQuery }, plan);
}
Also used : RelationalNode(org.teiid.query.processor.relational.RelationalNode) DependentProcedureExecutionNode(org.teiid.query.processor.relational.DependentProcedureExecutionNode) ProcedurePlan(org.teiid.query.processor.proc.ProcedurePlan) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) CreateCursorResultSetInstruction(org.teiid.query.processor.proc.CreateCursorResultSetInstruction)

Aggregations

RelationalPlan (org.teiid.query.processor.relational.RelationalPlan)40 Test (org.junit.Test)25 RelationalNode (org.teiid.query.processor.relational.RelationalNode)12 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)11 Command (org.teiid.query.sql.lang.Command)10 List (java.util.List)9 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)9 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)8 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)8 AccessNode (org.teiid.query.processor.relational.AccessNode)8 JoinNode (org.teiid.query.processor.relational.JoinNode)8 ArrayList (java.util.ArrayList)7 ProjectNode (org.teiid.query.processor.relational.ProjectNode)7 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)5 Annotation (org.teiid.client.plan.Annotation)4 AnalysisRecord (org.teiid.query.analysis.AnalysisRecord)4 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)4 LanguageObject (org.teiid.query.sql.LanguageObject)4 QueryPlannerException (org.teiid.api.exception.query.QueryPlannerException)3 CapabilitiesFinder (org.teiid.query.optimizer.capabilities.CapabilitiesFinder)3