use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestSubqueryPushdown method testSubqueryPlan.
@Test
public void testSubqueryPlan() throws Exception {
BasicSourceCapabilities bsc = getTypicalCapabilities();
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
"select 1, (select cast(stringkey as integer) from bqt1.smallb where intkey = smalla.intkey) from bqt1.smalla", RealMetadataFactory.exampleBQTCached(), null, new DefaultCapabilitiesFinder(bsc), new String[] { "SELECT g_0.IntKey FROM BQT1.SmallA AS g_0" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
assertEquals(6, plan.getDescriptionProperties().getProperties().size());
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestSubqueryPushdown method testNestedCorrelation.
@Test
public void testNestedCorrelation() throws Exception {
TransformationMetadata tm = RealMetadataFactory.fromDDL("CREATE foreign TABLE a (c1 integer, c2 integer); " + "CREATE foreign TABLE b (c3 integer, c4 integer); CREATE foreign TABLE c (c5 integer, c6 integer);", "x", "y");
String sql = "SELECT (select c2 from b where c3 = (select c5 from c where c6 = c1)) FROM a group by c1, c2";
BasicSourceCapabilities bsc = getTypicalCapabilities();
/*ProcessorPlan plan = TestOptimizer.helpPlan(sql, //$NON-NLS-1$
tm, null, new DefaultCapabilitiesFinder(bsc),
new String[] {
"SELECT g_0.c1, g_0.c2 FROM y.a AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
*/
HardcodedDataManager hdm = new HardcodedDataManager(tm);
hdm.addData("SELECT g_0.c1, g_0.c2 FROM a AS g_0", Arrays.asList(1, 2));
hdm.addData("SELECT g_0.c5 FROM c AS g_0 WHERE g_0.c6 = 1", Arrays.asList(1));
hdm.addData("SELECT 2 FROM b AS g_0 WHERE g_0.c3 = 1", Arrays.asList(2));
CommandContext cc = TestProcessor.createCommandContext();
cc.setMetadata(tm);
// TestProcessor.helpProcess(plan, cc, hdm, new List[] {Arrays.asList(2)} );
// with conflicting aliases it should still work
sql = "SELECT (select c2 from b where c3 = (select c5 from c as x where c6 = c1)) FROM a as x group by c1, c2";
/* plan = TestOptimizer.helpPlan(sql, //$NON-NLS-1$
tm, null, new DefaultCapabilitiesFinder(bsc),
new String[] {
"SELECT g_0.c1, g_0.c2 FROM y.a AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
TestProcessor.helpProcess(plan, cc, hdm, new List[] {Arrays.asList(2)} );
*/
// with conflicting aliases it should still work
sql = "SELECT (select c2 from b as x where c3 = (select c5 from c as x where c6 = c1)) FROM a as x group by c1, c2";
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
sql, tm, null, new DefaultCapabilitiesFinder(bsc), new String[] { "SELECT g_0.c1, g_0.c2 FROM y.a AS g_0" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
TestProcessor.helpProcess(plan, cc, hdm, new List[] { Arrays.asList(2) });
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestSubqueryPushdown method testDeleteSubqueryCorrelatedCompensated.
@Test
public void testDeleteSubqueryCorrelatedCompensated() throws Exception {
BasicSourceCapabilities bsc = getTypicalCapabilities();
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
"delete FROM pm1.g1 x where e1 = 'a' and e3 = (select e3 from pm1.g2 where e2 < x.e2)", RealMetadataFactory.example4(), null, new DefaultCapabilitiesFinder(bsc), new String[] {}, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager hcdm = new HardcodedDataManager();
hcdm.addData("SELECT g_0.e3, g_0.e2, g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 = 'a'", Arrays.asList(true, 1, 'a'));
hcdm.addData("SELECT g_0.e3 FROM pm1.g2 AS g_0 WHERE g_0.e2 < 1", Arrays.asList(true));
hcdm.addData("DELETE FROM pm1.g1 WHERE pm1.g1.e1 = 'a'", Arrays.asList(1));
TestProcessor.helpProcess(plan, hcdm, null);
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestSubqueryPushdown method testCorrelatedOnly.
/**
* Shows the uncorrelated subquery is evaluated ahead of time
*/
@Test
public void testCorrelatedOnly() throws Exception {
BasicSourceCapabilities bsc = getTypicalCapabilities();
bsc.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
bsc.setCapabilitySupport(Capability.QUERY_SUBQUERIES_ONLY_CORRELATED, true);
bsc.setCapabilitySupport(Capability.CRITERIA_EXISTS, true);
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
"SELECT 1 FROM bqt1.smalla where EXISTS (SELECT 'Y' FROM bqt1.mediuma)", RealMetadataFactory.exampleBQTCached(), null, new DefaultCapabilitiesFinder(bsc), new String[] { "SELECT 1 FROM BQT1.SmallA AS g_0 WHERE EXISTS (SELECT 'Y' FROM BQT1.MediumA AS g_0)" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager hcdm = new HardcodedDataManager(false);
TestProcessor.helpProcess(plan, hcdm, null);
assertEquals("SELECT 'Y' FROM BQT1.MediumA AS g_0", hcdm.getCommandHistory().get(0).toString());
assertEquals("SELECT 1 FROM BQT1.SmallA AS g_0", hcdm.getCommandHistory().get(1).toString());
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestSubqueryPushdown method testSubuqeryOn2.
/**
* Shows pushdown of on subquery with support
*/
@Test
public void testSubuqeryOn2() throws Exception {
BasicSourceCapabilities bsc = getTypicalCapabilities();
bsc.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
bsc.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
bsc.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, ExecutionFactory.SupportedJoinCriteria.ANY);
bsc.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
bsc.setCapabilitySupport(Capability.CRITERIA_EXISTS, true);
bsc.setCapabilitySupport(Capability.QUERY_FROM_ANSI_JOIN, true);
bsc.setCapabilitySupport(Capability.CRITERIA_ON_SUBQUERY, true);
// $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
"SELECT 1 FROM bqt1.smalla as Y93 LEFT OUTER JOIN bqt1.smallb as AG5 ON EXISTS (SELECT 'Y' FROM bqt1.mediuma WHERE AG5.intkey = 1 AND Y93.intkey = 1 )", RealMetadataFactory.exampleBQTCached(), null, new DefaultCapabilitiesFinder(bsc), new String[] { "SELECT 1 FROM BQT1.SmallA AS g_0 LEFT OUTER JOIN BQT1.SmallB AS g_1 ON EXISTS (SELECT 'Y' FROM BQT1.MediumA AS g_2 WHERE (g_1.IntKey = 1) AND (g_0.IntKey = 1))" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
}
Aggregations