use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testInvalidSource.
@Test(expected = QueryPlannerException.class)
public void testInvalidSource() throws Exception {
// $NON-NLS-1$
String sql = "select * from pm1.g1";
QueryMetadataInterface md = RealMetadataFactory.example1Cached();
QueryOptimizer.optimizePlan(helpGetCommand(sql, md, null), md, null, new DefaultCapabilitiesFinder() {
@Override
public boolean isValid(String modelName) {
return false;
}
}, null, new CommandContext());
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testUnnamedAggInView.
@Test
public void testUnnamedAggInView() throws Exception {
MetadataStore metadataStore = new MetadataStore();
// $NON-NLS-1$
Schema bqt1 = RealMetadataFactory.createPhysicalModel("BQT1", metadataStore);
// $NON-NLS-1$
Schema vqt = RealMetadataFactory.createVirtualModel("VQT", metadataStore);
// $NON-NLS-1$
Table bqt1SmallA = RealMetadataFactory.createPhysicalGroup("SmallA", bqt1);
RealMetadataFactory.createElement("col", bqt1SmallA, DataTypeManager.DefaultDataTypes.STRING);
Table agg3 = RealMetadataFactory.createVirtualGroup("Agg3", vqt, new QueryNode("select count(*) from smalla"));
RealMetadataFactory.createElement("count", agg3, DataTypeManager.DefaultDataTypes.INTEGER);
TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(metadataStore, "x");
BasicSourceCapabilities bac = getTypicalCapabilities();
bac.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
bac.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
bac.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
helpPlan("select count(*) from agg3", metadata, new String[] {}, new DefaultCapabilitiesFinder(bac), ComparisonMode.EXACT_COMMAND_STRING);
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestAggregatePushdown method testGroupByConstant.
@Test
public void testGroupByConstant() throws Exception {
BasicSourceCapabilities caps = getAggregateCapabilities();
caps.setCapabilitySupport(Capability.QUERY_FUNCTIONS_IN_GROUP_BY, true);
String sql = "SELECT x from (select 'aaa' as x FROM pm1.g1) AS g_0 GROUP BY x";
// $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
sql, // $NON-NLS-1$
RealMetadataFactory.example1Cached(), new String[] { "SELECT v_0.c_0 FROM (SELECT 'aaa' AS c_0 FROM pm1.g1 AS g_0) AS v_0 GROUP BY v_0.c_0" }, new DefaultCapabilitiesFinder(caps), ComparisonMode.EXACT_COMMAND_STRING);
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestAggregatePushdown method testRemoveRedundantDistinct.
@Test
public void testRemoveRedundantDistinct() throws Exception {
String sql = "SELECT distinct count(*) from bqt1.smalla";
BasicSourceCapabilities caps = getAggregateCapabilities();
// $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
sql, // $NON-NLS-1$
RealMetadataFactory.exampleBQTCached(), new String[] { "SELECT COUNT(*) FROM BQT1.SmallA AS g_0" }, new DefaultCapabilitiesFinder(caps), ComparisonMode.EXACT_COMMAND_STRING);
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestConformedTables method testConformedSubquery.
@Test
public void testConformedSubquery() throws Exception {
String sql = "select pm2.g2.e1 from pm2.g2 where e1 in /*+ no_unnest */ (select e1 from pm1.g1)";
BasicSourceCapabilities bsc = getTypicalCapabilities();
bsc.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
helpPlan(sql, tm, new String[] { "SELECT g_0.e1 FROM pm2.g2 AS g_0 WHERE g_0.e1 IN /*+ NO_UNNEST */ (SELECT g_1.e1 FROM pm1.g1 AS g_1)" }, new DefaultCapabilitiesFinder(bsc), ComparisonMode.EXACT_COMMAND_STRING);
// TODO: it should work either way, but for now we expect the subquery to conform to the parent
sql = "select pm1.g1.e1 from pm1.g1 where e2 in (select e2 from pm2.g2)";
}
Aggregations