use of org.teiid.query.optimizer.capabilities.BasicSourceCapabilities in project teiid by teiid.
the class TestAggregatePushdown method testAggregateOfJoinExpression.
/**
* Note that intnum is retrieved from each source
*
* Note also that this test shows that the max aggregate is not placed on the bqt2 query since it would be on one of the group by expressions
*/
@Test
public void testAggregateOfJoinExpression() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = getAggregateCapabilities();
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
// $NON-NLS-1$
caps.setFunctionSupport("convert", true);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
// $NON-NLS-1$
capFinder.addCapabilities("BQT2", caps);
// $NON-NLS-1$
String sql = "SELECT a12.intkey, MAX(a12.stringkey), MIN(a11.intnum+a12.intnum) FROM bqt1.smalla AS a11 INNER JOIN bqt2.smalla AS a12 ON a11.stringkey = a12.stringkey GROUP BY a12.intkey";
ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), null, capFinder, new String[] { "SELECT g_0.StringKey, g_0.IntKey, g_0.IntNum FROM BQT2.SmallA AS g_0 GROUP BY g_0.StringKey, g_0.IntKey, g_0.IntNum", "SELECT g_0.StringKey, g_0.IntNum FROM BQT1.SmallA AS g_0" }, // $NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
2, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
1, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
1, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
}
use of org.teiid.query.optimizer.capabilities.BasicSourceCapabilities in project teiid by teiid.
the class TestAggregatePushdown method testOuterJoinPushdown.
@Test
public void testOuterJoinPushdown() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = getAggregateCapabilities();
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
// $NON-NLS-1$
capFinder.addCapabilities("pm2", caps);
// $NON-NLS-1$
String sql = "SELECT count(y.e2) from pm1.g1 x left outer join pm2.g1 y on x.e4 = y.e4 group by x.e2, y.e1";
ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), null, capFinder, new String[] { "SELECT g_0.e4, g_0.e2 FROM pm1.g1 AS g_0", "SELECT g_0.e4, g_0.e1, COUNT(g_0.e2) FROM pm2.g1 AS g_0 GROUP BY g_0.e4, g_0.e1" }, // $NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
2, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
1, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
1, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
}
use of org.teiid.query.optimizer.capabilities.BasicSourceCapabilities in project teiid by teiid.
the class TestAggregatePushdown method testBusObjQuestion2HintVariation.
@Test
public void testBusObjQuestion2HintVariation() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = getTypicalCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
// $NON-NLS-1$
capFinder.addCapabilities("db2model", caps);
// $NON-NLS-1$
capFinder.addCapabilities("oraclemodel", caps);
// $NON-NLS-1$
capFinder.addCapabilities("msmodel", caps);
QueryMetadataInterface metadata = RealMetadataFactory.exampleBusObj();
String sql = // $NON-NLS-1$
"SELECT SUM(F.SALES), G.REGION, T.YEAR " + // $NON-NLS-1$
"FROM SALES F MAKEDEP, GEOGRAPHY2 G, msModel.TIME T " + // $NON-NLS-1$
"WHERE (F.CITY = G.CITY) AND (F.MONTH = T.MONTH) " + // $NON-NLS-1$
"AND G.REGION IN ('BORDEAUX', 'POLINESIA') AND T.YEAR = '1999' " + // $NON-NLS-1$
"GROUP BY G.REGION, T.YEAR";
ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, new String[] { "SELECT g_0.\"MONTH\" AS c_0, g_0.\"YEAR\" AS c_1 FROM msmodel.\"TIME\" AS g_0 WHERE g_0.\"YEAR\" = '1999' ORDER BY c_0", // $NON-NLS-1$
"SELECT g_0.\"MONTH\", g_1.REGION, SUM(g_0.SALES) FROM db2model.SALES AS g_0, db2model.GEOGRAPHY2 AS g_1 WHERE (g_0.CITY = g_1.CITY) AND (g_1.REGION IN ('BORDEAUX', 'POLINESIA')) AND (g_0.\"MONTH\" IN (<dependent values>)) GROUP BY g_0.\"MONTH\", g_1.REGION" }, ComparisonMode.EXACT_COMMAND_STRING);
checkNodeTypes(plan, new int[] { // Access
1, // DependentAccess
1, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
1, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
1, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
}
use of org.teiid.query.optimizer.capabilities.BasicSourceCapabilities in project teiid by teiid.
the class TestAggregatePushdown method testStringAggPushdown.
@Test
public void testStringAggPushdown() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = getAggregateCapabilities();
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_STRING, true);
caps.setCapabilitySupport(Capability.WINDOW_FUNCTION_ORDER_BY_AGGREGATES, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
"select string_agg(e1, ',') from pm1.g2 group by e1", // $NON-NLS-1$
RealMetadataFactory.example1Cached(), // $NON-NLS-1$
null, // $NON-NLS-1$
capFinder, new String[] { "SELECT string_agg(g_0.e1, ',') FROM pm1.g2 AS g_0 GROUP BY g_0.e1" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
use of org.teiid.query.optimizer.capabilities.BasicSourceCapabilities in project teiid by teiid.
the class TestAggregatePushdown method testCase6211.
/**
* Test of an aggregate nested in an expression symbol
*/
@Test
public void testCase6211() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = getAggregateCapabilities();
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
// $NON-NLS-1$
caps.setFunctionSupport("convert", true);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
// $NON-NLS-1$
capFinder.addCapabilities("BQT2", caps);
// $NON-NLS-1$
String sql = "select sum(a11.intnum) Profit, (sum(a11.intnum) / sum(a11.floatnum)) WJXBFS2 from bqt1.smalla a11 join bqt2.smallb a12 on a11.intkey=a12.intkey group by a12.intkey";
ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), null, capFinder, new String[] { "SELECT g_0.IntKey FROM BQT2.SmallB AS g_0", "SELECT g_0.IntKey, SUM(g_0.IntNum), SUM(g_0.FloatNum) FROM BQT1.SmallA AS g_0 GROUP BY g_0.IntKey" }, // $NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
2, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
1, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
1, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
}
Aggregations