use of org.teiid.query.optimizer.capabilities.CapabilitiesFinder in project teiid by teiid.
the class TestDefaultCapabilitiesFinder method testFindCapabilities.
public void testFindCapabilities() throws Exception {
CapabilitiesFinder capFinder = new DefaultCapabilitiesFinder();
// $NON-NLS-1$
SourceCapabilities caps = capFinder.findCapabilities("blah");
// $NON-NLS-1$
assertNotNull("Default capabilities should not be null", caps);
}
use of org.teiid.query.optimizer.capabilities.CapabilitiesFinder in project teiid by teiid.
the class TestProcessor method testPushdownInlineViewNotRemoved.
@Test
public void testPushdownInlineViewNotRemoved() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.fromDDL("create foreign table test_a (a integer, b integer)", "x", "y");
BasicSourceCapabilities caps = getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, true);
caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
caps.setCapabilitySupport(Capability.QUERY_UNION, true);
CapabilitiesFinder capFinder = new DefaultCapabilitiesFinder(caps);
String sql = "select CustomerType from (select 'a' as CustomerType, view1.* \n" + " from (select min(a) as FirstOrderDate, count(b), b \n" + " from (SELECT * FROM test_a) as pixiGetOrderHeader group by b) as NewCustomerTable, (SELECT * FROM test_a) view1 \n" + " where view1.a = NewCustomerTable.b and view1.b = NewCustomerTable.FirstOrderDate \n" + " UNION select 'Existing Customer' as CustomerType, view1.* \n" + " from (select min(a) as FirstOrderDate, count(b), b \n" + " from (SELECT * FROM test_a) view1 group by b) as NewCustomerTable, (SELECT * FROM test_a) view1 \n" + " where view1.a = NewCustomerTable.b and view1.b != NewCustomerTable.FirstOrderDate) as view2";
ProcessorPlan plan = helpPlan(// $NON-NLS-1
sql, // $NON-NLS-1
metadata, null, capFinder, new String[] { "SELECT v_2.c_0 FROM (SELECT 'a' AS c_0, g_3.a AS c_1, g_3.b AS c_2 FROM (SELECT g_2.b AS c_0, MIN(g_2.a) AS c_1 FROM y.test_a AS g_2 GROUP BY g_2.b) AS v_1, y.test_a AS g_3 WHERE (g_3.a = v_1.c_0) AND (g_3.b = v_1.c_1) UNION SELECT 'Existing Customer' AS c_0, g_1.a AS c_1, g_1.b AS c_2 FROM (SELECT g_0.b AS c_0, MIN(g_0.a) AS c_1 FROM y.test_a AS g_0 GROUP BY g_0.b) AS v_0, y.test_a AS g_1 WHERE (g_1.a = v_0.c_0) AND (g_1.b <> v_0.c_1)) AS v_2" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
CommandContext cc = createCommandContext();
HardcodedDataManager hdm = new HardcodedDataManager();
hdm.addData("SELECT v_2.c_0 FROM (SELECT 'a' AS c_0, g_3.a AS c_1, g_3.b AS c_2 FROM (SELECT g_2.b AS c_0, MIN(g_2.a) AS c_1 FROM y.test_a AS g_2 GROUP BY g_2.b) AS v_1, y.test_a AS g_3 WHERE (g_3.a = v_1.c_0) AND (g_3.b = v_1.c_1) UNION SELECT 'Existing Customer' AS c_0, g_1.a AS c_1, g_1.b AS c_2 FROM (SELECT g_0.b AS c_0, MIN(g_0.a) AS c_1 FROM y.test_a AS g_0 GROUP BY g_0.b) AS v_0, y.test_a AS g_1 WHERE (g_1.a = v_0.c_0) AND (g_1.b <> v_0.c_1)) AS v_2", Arrays.asList("a"));
helpProcess(plan, cc, hdm, new List<?>[] { Arrays.asList("a") });
}
use of org.teiid.query.optimizer.capabilities.CapabilitiesFinder in project teiid by teiid.
the class TestFunctionPushdown method testMustPushdownOverGrouping.
@Test
public void testMustPushdownOverGrouping() throws Exception {
TransformationMetadata tm = RealMetadataFactory.fromDDL("create foreign function func (param integer) returns integer; create foreign table g1 (e1 integer)", "x", "y");
BasicSourceCapabilities bsc = new BasicSourceCapabilities();
bsc.setCapabilitySupport(Capability.SELECT_WITHOUT_FROM, true);
bsc.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
final DefaultCapabilitiesFinder capFinder = new DefaultCapabilitiesFinder(bsc);
CommandContext cc = TestProcessor.createCommandContext();
cc.setQueryProcessorFactory(new QueryProcessor.ProcessorFactory() {
@Override
public PreparedPlan getPreparedPlan(String query, String recursionGroup, CommandContext commandContext, QueryMetadataInterface metadata) throws TeiidProcessingException, TeiidComponentException {
return null;
}
@Override
public CapabilitiesFinder getCapabiltiesFinder() {
return capFinder;
}
@Override
public QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext, Object... params) throws TeiidProcessingException, TeiidComponentException {
// TODO Auto-generated method stub
return null;
}
});
cc.setMetadata(tm);
// $NON-NLS-1$
String sql = "select func(e1) from g1 group by e1";
ProcessorPlan plan = helpPlan(sql, tm, null, capFinder, new String[] { "SELECT y.g1.e1 FROM y.g1" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT y.g1.e1 FROM y.g1", new List[] { Arrays.asList(1), Arrays.asList(2) });
dataManager.addData("SELECT func(1)", new List[] { Arrays.asList(2) });
dataManager.addData("SELECT func(2)", new List[] { Arrays.asList(3) });
TestProcessor.helpProcess(plan, cc, dataManager, new List[] { Arrays.asList(2), Arrays.asList(3) });
}
use of org.teiid.query.optimizer.capabilities.CapabilitiesFinder in project teiid by teiid.
the class TestMaterialization method execute.
private void execute(String sql, List<?>... expectedResults) throws Exception {
CommandContext cc = TestProcessor.createCommandContext();
cc.setTempTableStore(tempStore);
cc.setGlobalTableStore(globalStore);
cc.setMetadata(metadata);
CapabilitiesFinder finder = new DefaultCapabilitiesFinder();
previousPlan = TestProcessor.helpGetPlan(TestProcessor.helpParse(sql), metadata, finder, cc);
cc.setQueryProcessorFactory(new QueryProcessorFactoryImpl(BufferManagerFactory.getStandaloneBufferManager(), dataManager, finder, null, metadata));
TestProcessor.doProcess(previousPlan, dataManager, expectedResults, cc);
}
use of org.teiid.query.optimizer.capabilities.CapabilitiesFinder in project teiid by teiid.
the class TestAggregateProcessing method testDuplicateGroupBy.
// TODO: the rewriter may need to correct this case, but at least the grouping node can
// now handle it
@Test
public void testDuplicateGroupBy() {
// $NON-NLS-1$
Command command = helpParse("select e2 from pm1.g1 group by e2, e2");
CapabilitiesFinder capFinder = TestOptimizer.getGenericFinder();
HardcodedDataManager dataManager = new HardcodedDataManager();
// $NON-NLS-1$
dataManager.addData(// $NON-NLS-1$
"SELECT g_0.e2 FROM pm1.g1 AS g_0", new List[] { // $NON-NLS-1$
Arrays.asList(1), // $NON-NLS-1$
Arrays.asList(2), // $NON-NLS-1$
Arrays.asList(2) });
ProcessorPlan plan = helpGetPlan(command, RealMetadataFactory.example1Cached(), capFinder);
List[] expected = new List[] { Arrays.asList(1), Arrays.asList(2) };
helpProcess(plan, dataManager, expected);
}
Aggregations