use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestAggregatePushdown method testUserDefinedAggPushdown.
@Test
public void testUserDefinedAggPushdown() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = getAggregateCapabilities();
caps.setCapabilitySupport(Capability.ELEMENTARY_OLAP, true);
caps.setCapabilitySupport(Capability.WINDOW_FUNCTION_DISTINCT_AGGREGATES, true);
caps.setCapabilitySupport(Capability.WINDOW_FUNCTION_ORDER_BY_AGGREGATES, true);
caps.setFunctionSupport("FIRST_VALUE", true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
QueryMetadataInterface metadata = RealMetadataFactory.createTransformationMetadata(RealMetadataFactory.example1Cached().getMetadataStore(), "example1", new FunctionTree("foo", new FakeFunctionMetadataSource(), true));
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
"select foo.FIRST_VALUE(e1) OVER (ORDER BY e2) from pm1.g2", // $NON-NLS-1$
metadata, // $NON-NLS-1$
null, // $NON-NLS-1$
capFinder, new String[] { "SELECT foo.FIRST_VALUE(ALL g_0.e1) OVER (ORDER BY g_0.e2) FROM pm1.g2 AS g_0" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestAggregatePushdown method testAggregatePushdown2.
@Test
public void testAggregatePushdown2() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.exampleAggregatesCached();
String sql = // $NON-NLS-1$
"SELECT o_dealerid, o_productid, sum(o_amount) FROM m1.order, m1.dealer, m2.product " + // $NON-NLS-1$
"WHERE o_dealerid=d_dealerid AND o_productid=p_productid AND d_state = 'CA' AND p_divid = 100 " + // $NON-NLS-1$
"GROUP BY o_dealerid, o_productid having max(o_amount) < 100";
ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, null, getAggregatesFinder(), // $NON-NLS-1$ //$NON-NLS-2$
new String[] { "SELECT g_0.P_ProductID AS c_0 FROM m2.product AS g_0 WHERE g_0.P_DivID = 100 ORDER BY c_0", "SELECT g_0.O_ProductID, g_0.O_DealerID, MAX(g_0.O_Amount), SUM(g_0.O_Amount) FROM m1.\"order\" AS g_0, m1.dealer AS g_1 WHERE (g_0.O_DealerID = g_1.D_DealerID) AND (g_1.D_State = 'CA') AND (g_0.O_ProductID IN (<dependent values>)) GROUP BY g_0.O_ProductID, g_0.O_DealerID" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.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
1, // Sort
0, // UnionAll
0 });
}
use of org.teiid.query.metadata.QueryMetadataInterface 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.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestAggregatePushdown method testBusObjQuestion3.
@Test
public void testBusObjQuestion3() {
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();
// $NON-NLS-1$
String sql = "select sum(c0), sum(b0), c1, b2 FROM db2Table, OraTable where c2=b2 group by c1, b2";
ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, new String[] { // $NON-NLS-1$
"SELECT g_0.c2, g_0.c1, g_0.c0 FROM db2model.DB2TABLE AS g_0", // $NON-NLS-1$
"SELECT g_0.b2 AS c_0, g_0.b0 AS c_1 FROM oraclemodel.OraTable AS g_0 ORDER BY c_0" }, SHOULD_SUCCEED);
checkNodeTypes(plan, new int[] { // Access
2, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
2, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
1, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestAggregatePushdown method testNoHavingAggregate.
@Test
public void testNoHavingAggregate() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
ProcessorPlan plan = TestOptimizer.helpPlan(// $NON-NLS-1$
"select stringkey, max(intkey) from bqt1.smalla group by stringkey having count(intkey) = 1", metadata, null, capFinder, new String[] { // $NON-NLS-1$
"SELECT COUNT(g_0.IntKey), g_0.StringKey, MAX(g_0.IntKey) FROM BQT1.SmallA AS g_0 GROUP BY g_0.StringKey" }, ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
1, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
0, // Null
0, // PlanExecution
0, // Project
1, // Select
1, // Sort
0, // UnionAll
0 });
}
Aggregations