use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestJoinOptimization method testMergeJoinOrderNotPushed1.
/**
* Same as above but using the system/option property
* @throws TeiidComponentException
* @throws TeiidProcessingException
*/
@Test
public void testMergeJoinOrderNotPushed1() throws Exception {
String sql = "select bqt1.smalla.intkey, bqt2.smalla.intkey " + // $NON-NLS-1$
"from bqt1.smalla inner join bqt2.smalla on (bqt2.smalla.stringkey = bqt1.smalla.stringkey)";
BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();
bsc.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
CommandContext cc = TestProcessor.createCommandContext();
cc.getOptions().setAssumeMatchingCollation(false);
// Plan query
ProcessorPlan plan = TestProcessor.helpGetPlan(TestOptimizer.helpGetCommand(sql, RealMetadataFactory.exampleBQTCached(), null), RealMetadataFactory.exampleBQTCached(), new DefaultCapabilitiesFinder(bsc), cc);
HardcodedDataManager hdm = new HardcodedDataManager();
hdm.addData("SELECT g_0.StringKey, g_0.IntKey FROM BQT1.SmallA AS g_0", Arrays.asList("b", 1), Arrays.asList("a", 3));
hdm.addData("SELECT g_0.StringKey, g_0.IntKey FROM BQT2.SmallA AS g_0", Arrays.asList("c", 1), Arrays.asList("a", 2));
TestProcessor.helpProcess(plan, hdm, new List<?>[] { Arrays.asList(3, 2) });
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestJoinOptimization method testInnerOuterOptimizationCrossJoin.
@Test
public void testInnerOuterOptimizationCrossJoin() throws TeiidComponentException, TeiidProcessingException {
// $NON-NLS-1$
String sql = "select pm1.g2.e2, pm1.g3.e2, pm1.g4.e1, pm1.g4.e3 from ((pm1.g2 cross join pm1.g3) inner join pm1.g1 on pm1.g1.e1 = pm1.g2.e1) left outer join pm1.g4 on (pm1.g2.e4 = pm1.g4.e4)";
BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();
DefaultCapabilitiesFinder capFinder = new DefaultCapabilitiesFinder(bsc);
TransformationMetadata tm = RealMetadataFactory.example1();
RealMetadataFactory.setCardinality("pm1.g1", 1, tm);
RealMetadataFactory.setCardinality("pm1.g2", 1, tm);
RealMetadataFactory.setCardinality("pm1.g3", 1, tm);
// $NON-NLS-1$ //$NON-NLS-2$
ProcessorPlan plan = TestOptimizer.helpPlan(sql, tm, new String[] { "SELECT g_2.e2, g_0.e2, g_3.e1, g_3.e3 FROM (pm1.g3 AS g_0 CROSS JOIN pm1.g1 AS g_1) INNER JOIN (pm1.g2 AS g_2 LEFT OUTER JOIN pm1.g4 AS g_3 ON g_2.e4 = g_3.e4) ON g_1.e1 = g_2.e1" }, capFinder, ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestJoinOptimization method testCopyCriteriaWithFunction3.
@Test
public void testCopyCriteriaWithFunction3() throws TeiidComponentException, TeiidProcessingException {
// $NON-NLS-1$
String sql = "select bqt1.smalla.intkey, bqt1.smallb.intkey from bqt1.smalla, bqt1.smallb where bqt1.smalla.stringkey = bqt1.smallb.intkey and bqt1.smallb.intkey = 1";
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
// Plan query
// $NON-NLS-1$ //$NON-NLS-2$
ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), new String[] { "SELECT g_0.IntKey, g_1.IntKey FROM BQT1.SmallA AS g_0, BQT1.SmallB AS g_1 WHERE (g_0.StringKey = '1') AND (g_1.IntKey = 1)" }, new DefaultCapabilitiesFinder(caps), ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.THETA);
// $NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), new String[] { "SELECT g_0.IntKey FROM BQT1.SmallA AS g_0 WHERE g_0.StringKey = '1'", "SELECT g_0.IntKey FROM BQT1.SmallB AS g_0 WHERE g_0.IntKey = 1" }, new DefaultCapabilitiesFinder(caps), ComparisonMode.EXACT_COMMAND_STRING);
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestJoinOptimization method testFullOuterJoinPredicatePlacement.
@Test
public void testFullOuterJoinPredicatePlacement() throws TeiidComponentException, TeiidProcessingException {
// $NON-NLS-1$
String sql = "select b1.intkey, b2.intkey from (select * from bqt1.smalla where bqt1.smalla.stringkey = 'a') b1 full outer join (select * from bqt1.smallb where bqt1.smallb.stringkey = 'b') b2 on (b1.intkey = b2.intkey)";
BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();
bsc.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
bsc.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, false);
TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), new String[] { "SELECT g_0.IntKey FROM BQT1.SmallA AS g_0 WHERE g_0.StringKey = 'a'", "SELECT g_0.IntKey FROM BQT1.SmallB AS g_0 WHERE g_0.StringKey = 'b'" }, new DefaultCapabilitiesFinder(bsc), // $NON-NLS-1$ //$NON-NLS-2$
ComparisonMode.EXACT_COMMAND_STRING);
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestJoinPushdownRestrictions method testOuterRestrictionMultiLevel.
@Test
public void testOuterRestrictionMultiLevel() throws Exception {
String ddl = "create foreign table g1 (e1 integer primary key, e2 integer); " + "create foreign table g2 (e1 integer primary key, e2 integer, FOREIGN KEY (e2) REFERENCES g1 (e1));" + "create foreign table g3 (e1 integer primary key, e2 integer, FOREIGN KEY (e2) REFERENCES g2 (e1));";
// $NON-NLS-1$
String sql = "select g1.e2, g2.e2 from g1, g2, g3 where g1.e1 = g2.e2 and g2.e1 = g3.e2";
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, false);
caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.KEY);
TestOptimizer.helpPlan(sql, RealMetadataFactory.fromDDL(ddl, "x", "y"), new String[] { "SELECT g_1.e2, g_2.e2 FROM y.g3 AS g_0 LEFT OUTER JOIN (y.g1 AS g_1 LEFT OUTER JOIN y.g2 AS g_2 ON g_1.e1 = g_2.e2) ON g_2.e1 = g_0.e2 WHERE g_2.e2 IS NOT NULL" }, new DefaultCapabilitiesFinder(caps), // $NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
}
Aggregations