use of org.teiid.query.processor.relational.JoinNode in project teiid by teiid.
the class TestProcessor method testComplexJoinExpressionsUsingDependentJoin.
/**
* RLM Case 2077
* @throws Exception
*/
@Test
public void testComplexJoinExpressionsUsingDependentJoin() throws Exception {
// $NON-NLS-1$
String sql = "SELECT a.e1, b.e1, b.e2 FROM pm1.g1 a, pm2.g1 b where rtrim(a.e1)=(b.e1 || b.e1)";
// Create expected results
List[] expected = new List[] { // $NON-NLS-1$ //$NON-NLS-2$
Arrays.asList(new Object[] { "bb ", "b", new Integer(0) }) };
// Plan query
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
// $NON-NLS-1$
caps.setFunctionSupport("||", true);
// $NON-NLS-1$
caps.setFunctionSupport("rtrim", true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
// $NON-NLS-1$
capFinder.addCapabilities("pm2", caps);
QueryMetadataInterface metadata = RealMetadataFactory.example1();
RealMetadataFactory.setCardinality("pm1.g1", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata);
RealMetadataFactory.setCardinality("pm2.g1", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata);
// Construct data manager with data
FakeDataManager dataManager = new FakeDataManager();
sampleData2b(dataManager, metadata);
Command command = helpParse(sql);
CommandContext context = createCommandContext();
context.setMetadata(metadata);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
// 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);
// Run query
helpProcess(plan, context, dataManager, expected);
}
use of org.teiid.query.processor.relational.JoinNode in project teiid by teiid.
the class TestDependentJoins method helpTestDepAccessCausingSortNodeInsert.
public void helpTestDepAccessCausingSortNodeInsert(boolean accessNodeHandlesAliases) {
// $NON-NLS-1$
String sql = "SELECT a.e1, b.e1, b.e2 FROM pm4.g1 a INNER JOIN pm1.g1 b ON a.e2=b.e2 AND a.e1 = b.e1 OPTION MAKEDEP a";
// Create expected results
List[] expected = new List[] { // $NON-NLS-1$ //$NON-NLS-2$
Arrays.asList(new Object[] { "aa ", "aa ", 0 }), // $NON-NLS-1$ //$NON-NLS-2$
Arrays.asList(new Object[] { "bb ", "bb ", 1 }), // $NON-NLS-1$ //$NON-NLS-2$
Arrays.asList(new Object[] { "cc ", "cc ", 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);
if (accessNodeHandlesAliases) {
depcaps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, 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);
// Slightly modify metadata to set max set size to just a few rows - this
// will allow us to test the dependent overflow case
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.JoinNode in project teiid by teiid.
the class TestTextTable method testTextTableJoin.
@Test
public void testTextTableJoin() throws Exception {
String sql = "select z.* from (select x.* from (select * from pm1.g1 where e1 = 'c') y, texttable(e1 || '\n' || e2 || '\n' || e3 COLUMNS x string) x) as z, " + "(select x.* from (select * from pm1.g1 where e1 = 'c') y, texttable(e1 || '\n' || e2 || '\n' || e3 COLUMNS x string) x) as z1 where z.x = z1.x";
List<?>[] expected = new List<?>[] { Arrays.asList("c"), Arrays.asList("1"), Arrays.asList("true") };
FakeDataManager dataManager = new FakeDataManager();
sampleData1(dataManager);
RelationalPlan plan = (RelationalPlan) helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached());
JoinNode join = (JoinNode) plan.getRootNode().getChildren()[0];
assertTrue(!(join.getJoinStrategy() instanceof NestedTableJoinStrategy));
helpProcess(plan, createCommandContext(), dataManager, expected);
}
use of org.teiid.query.processor.relational.JoinNode in project teiid by teiid.
the class TestEnginePerformance method helpTestEquiJoin.
public void helpTestEquiJoin(int expectedRowCount, List<?>[] leftData, List<?>[] rightData, List<? extends Expression> elems, BufferManager bufferManager, JoinStrategy joinStrategy, JoinType joinType) throws TeiidComponentException, TeiidProcessingException {
// $NON-NLS-1$ //$NON-NLS-2$
CommandContext context = new CommandContext("pid", "test", null, null, 1);
FakeRelationalNode dataNode1 = new FakeRelationalNode(1, leftData);
dataNode1.setElements(elems);
dataNode1.initialize(context, bufferManager, null);
FakeRelationalNode dataNode2 = new FakeRelationalNode(2, rightData);
dataNode2.setElements(elems);
dataNode2.initialize(context, bufferManager, null);
JoinNode join = new JoinNode(3);
join.addChild(dataNode1);
join.addChild(dataNode2);
join.setJoinStrategy(joinStrategy.clone());
join.setElements(elems);
join.setJoinType(joinType);
join.setJoinExpressions(elems.subList(0, 1), elems.subList(0, 1));
join.initialize(context, bufferManager, null);
process(join, expectedRowCount);
}
Aggregations