use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestSubqueryPushdown method testNestedSubquerySemiJoin1.
/**
* Similar to the above, but uses a view for the most outer reference, which was
* causing the middle table reference to be inappropriately replaced.
* @throws Exception
*/
@Test
public void testNestedSubquerySemiJoin1() throws Exception {
String sql = "SELECT intkey FROM (select * from bqt1.smalla) AS A WHERE INTKEY IN /*+ mj */ (SELECT CONVERT(STRINGKEY, INTEGER) FROM bqt1.smalla AS A WHERE STRINGKEY IN (SELECT CONVERT(INTKEY, STRING) FROM BQT1.SMALLA AS B WHERE A.INTNUM = B.INTNUM))";
BasicSourceCapabilities bsc = getTypicalCapabilities();
ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), null, new DefaultCapabilitiesFinder(bsc), new String[] { "SELECT g_0.IntKey AS c_0 FROM BQT1.SmallA AS g_0 WHERE g_0.IntKey IN (<dependent values>) ORDER BY c_0" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager hdm = new HardcodedDataManager();
hdm.addData("SELECT g_0.StringKey, g_0.IntNum FROM BQT1.SmallA AS g_0", Arrays.asList("1", 1), Arrays.asList("2", 2));
hdm.addData("SELECT g_0.IntKey AS c_0 FROM BQT1.SmallA AS g_0 WHERE g_0.IntKey IN (1, 2) ORDER BY c_0", Arrays.asList(1));
hdm.addData("SELECT g_0.IntKey FROM BQT1.SmallA AS g_0 WHERE g_0.IntNum = 1", Arrays.asList(1));
hdm.addData("SELECT g_0.IntKey FROM BQT1.SmallA AS g_0 WHERE g_0.IntNum = 2", Arrays.asList(2));
TestProcessor.helpProcess(plan, hdm, new List[] { Arrays.asList(1) });
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestSubqueryPushdown method testNManySubqueryProcessingFalsePredicate.
@Test
public void testNManySubqueryProcessingFalsePredicate() throws Exception {
// $NON-NLS-1$
String sql = "SELECT INTKEY, FLOATNUM FROM BQT1.SMALLA AS A WHERE FLOATNUM = /*+ NO_UNNEST */ (SELECT MIN(FLOATNUM) FROM BQT1.SMALLA AS B WHERE (INTKEY >= 9) AND (A.INTKEY = B.INTKEY))";
TransformationMetadata metadata = RealMetadataFactory.exampleBQT();
HardcodedDataManager dataMgr = new HardcodedDataManager(metadata);
dataMgr.addData("SELECT g_0.FloatNum, g_0.IntKey FROM SmallA AS g_0", Arrays.asList(.1f, 1));
dataMgr.addData("SELECT MIN(g_0.FloatNum) FROM SmallA AS g_0 WHERE g_0.IntKey >= 9 AND g_0.IntKey = 1");
BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();
bsc.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
bsc.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, true);
bsc.setCapabilitySupport(Capability.CRITERIA_ONLY_LITERAL_COMPARE, true);
ProcessorPlan pp = TestProcessor.helpGetPlan(sql, metadata, new DefaultCapabilitiesFinder(bsc));
TestProcessor.helpProcess(pp, dataMgr, new List[] {});
sql = "SELECT INTKEY, STRINGKEY, DOUBLENUM FROM BQT1.SMALLA GROUP BY INTKEY, STRINGKEY, DOUBLENUM HAVING DOUBLENUM = /*+ NO_UNNEST */ (SELECT DOUBLENUM FROM BQT1.SMALLA WHERE STRINGKEY = 20)";
pp = TestProcessor.helpGetPlan(sql, metadata, new DefaultCapabilitiesFinder(bsc));
dataMgr.clearData();
dataMgr.addData("SELECT g_0.DoubleNum FROM SmallA AS g_0 WHERE g_0.StringKey = '20'");
TestProcessor.helpProcess(pp, dataMgr, new List[] {});
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestSubqueryPushdown method testNestedSubquerySemiJoin.
@Test
public void testNestedSubquerySemiJoin() throws Exception {
String sql = "SELECT intkey FROM BQT1.SmallA AS A WHERE INTKEY IN /*+ mj */ (SELECT CONVERT(STRINGKEY, INTEGER) FROM BQT1.SMALLA AS A WHERE STRINGKEY IN (SELECT CONVERT(INTKEY, STRING) FROM BQT1.SMALLA AS B WHERE A.INTNUM = B.INTNUM))";
BasicSourceCapabilities bsc = getTypicalCapabilities();
ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), null, new DefaultCapabilitiesFinder(bsc), new String[] { "SELECT g_0.IntKey AS c_0 FROM BQT1.SmallA AS g_0 WHERE g_0.IntKey IN (<dependent values>) ORDER BY c_0" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager hdm = new HardcodedDataManager();
hdm.addData("SELECT g_0.StringKey, g_0.IntNum FROM BQT1.SmallA AS g_0", Arrays.asList("1", 1), Arrays.asList("2", 2));
hdm.addData("SELECT g_0.IntKey AS c_0 FROM BQT1.SmallA AS g_0 WHERE g_0.IntKey IN (1, 2) ORDER BY c_0", Arrays.asList(1));
hdm.addData("SELECT g_0.IntKey FROM BQT1.SmallA AS g_0 WHERE g_0.IntNum = 1", Arrays.asList(1));
hdm.addData("SELECT g_0.IntKey FROM BQT1.SmallA AS g_0 WHERE g_0.IntNum = 2", Arrays.asList(2));
TestProcessor.helpProcess(plan, hdm, new List[] { Arrays.asList(1) });
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestSubqueryPushdown method testNestedSubquerySemiJoin2.
@Test
public void testNestedSubquerySemiJoin2() throws Exception {
String sql = "SELECT intkey FROM bqt1.smalla AS A WHERE INTKEY IN /*+ mj */ (SELECT CONVERT(STRINGKEY, INTEGER) FROM (select * from bqt1.smalla) AS A WHERE STRINGKEY IN (SELECT CONVERT(INTKEY, STRING) FROM BQT1.SMALLA AS B WHERE A.INTNUM = B.INTNUM))";
BasicSourceCapabilities bsc = getTypicalCapabilities();
ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), null, new DefaultCapabilitiesFinder(bsc), new String[] { "SELECT g_0.IntKey AS c_0 FROM BQT1.SmallA AS g_0 WHERE g_0.IntKey IN (<dependent values>) ORDER BY c_0" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager hdm = new HardcodedDataManager();
hdm.addData("SELECT g_0.StringKey, g_0.IntNum FROM BQT1.SmallA AS g_0", Arrays.asList("1", 1), Arrays.asList("2", 2));
hdm.addData("SELECT g_0.IntKey AS c_0 FROM BQT1.SmallA AS g_0 WHERE g_0.IntKey IN (1, 2) ORDER BY c_0", Arrays.asList(1));
hdm.addData("SELECT g_0.IntKey FROM BQT1.SmallA AS g_0 WHERE g_0.IntNum = 1", Arrays.asList(1));
hdm.addData("SELECT g_0.IntKey FROM BQT1.SmallA AS g_0 WHERE g_0.IntNum = 2", Arrays.asList(2));
TestProcessor.helpProcess(plan, hdm, new List[] { Arrays.asList(1) });
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestSubqueryPushdown method testSubqueryProducingBuffer.
@Test
public void testSubqueryProducingBuffer() throws Exception {
TransformationMetadata tm = RealMetadataFactory.example1Cached();
String sql = "SELECT e1, (select e2 from pm2.g1 where e1 = pm1.g1.e1 order by e2 limit 1) from pm1.g1 limit 1";
BasicSourceCapabilities bsc = getTypicalCapabilities();
bsc.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
sql, tm, null, new DefaultCapabilitiesFinder(bsc), new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager hdm = new HardcodedDataManager(tm) {
@Override
public TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject) throws TeiidComponentException {
if (command.toString().equals("SELECT g_0.e2 FROM pm2.g1 AS g_0 WHERE g_0.e1 = 'a'")) {
return new TupleSource() {
@Override
public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException {
throw new TeiidProcessingException("something's wrong");
}
@Override
public void closeSource() {
}
};
}
return super.registerRequest(context, command, modelName, parameterObject);
}
};
hdm.addData("SELECT g_0.e1 FROM g1 AS g_0", Arrays.asList("a"));
hdm.setBlockOnce(true);
CommandContext cc = TestProcessor.createCommandContext();
cc.setMetadata(tm);
try {
TestProcessor.helpProcess(plan, cc, hdm, new List[] { Arrays.asList(2) });
fail();
} catch (TeiidProcessingException e) {
assert (e.getMessage().contains("something's wrong"));
}
}
Aggregations