use of org.teiid.query.processor.relational.RelationalNode in project teiid by teiid.
the class TestDependentJoins method testNestedLeftOuterJoin.
@Test
public void testNestedLeftOuterJoin() throws TeiidComponentException, TeiidProcessingException {
// $NON-NLS-1$
String sql = "select pm1.g1.e2, 'a', trim(pm1.g3.e1) from (pm1.g1 left outer join pm1.g2 on pm1.g1.e2 = pm1.g2.e2) left outer join pm1.g3 on pm1.g3.e3 = pm1.g2.e3 and pm1.g3.e4 = pm1.g1.e4";
QueryMetadataInterface metadata = RealMetadataFactory.example1();
// $NON-NLS-1$
RealMetadataFactory.setCardinality("pm1.g2", 6, metadata);
// $NON-NLS-1$
RealMetadataFactory.setCardinality("pm1.g1", 0, metadata);
// $NON-NLS-1$
RealMetadataFactory.setCardinality("pm1.g3", 0, metadata);
CapabilitiesFinder finder = TestOptimizer.getGenericFinder(false);
ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, new String[] { "SELECT g_0.e3, g_0.e4, g_0.e1 FROM pm1.g3 AS g_0", "SELECT g_0.e2, g_0.e4 FROM pm1.g1 AS g_0", "SELECT g_0.e2, g_0.e3 FROM pm1.g2 AS g_0 WHERE g_0.e2 IN (<dependent values>)" }, finder, ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
2, // DependentAccess
1, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // Join
0, // MergeJoin
2, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
RelationalPlan rPlan = (RelationalPlan) plan;
RelationalNode node = rPlan.getRootNode().getChildren()[0];
assertTrue(node instanceof JoinNode);
node = node.getChildren()[0];
assertTrue(node instanceof JoinNode);
assertEquals(JoinType.JOIN_LEFT_OUTER, ((JoinNode) node).getJoinType());
}
use of org.teiid.query.processor.relational.RelationalNode 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));
}
use of org.teiid.query.processor.relational.RelationalNode 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());
}
use of org.teiid.query.processor.relational.RelationalNode 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);
}
use of org.teiid.query.processor.relational.RelationalNode 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);
}
Aggregations