use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestPartitionedJoinPlanning method testUsePartitionedMergeJoin.
@Test
public void testUsePartitionedMergeJoin() throws Exception {
// Create query
// $NON-NLS-1$
String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, 10);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
QueryMetadataInterface metadata = RealMetadataFactory.example1();
RealMetadataFactory.setCardinality("pm1.g1", BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE * 2, metadata);
RealMetadataFactory.setCardinality("pm1.g2", BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE * 16, metadata);
ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 ORDER BY pm1.g1.e1", "SELECT pm1.g2.e1 FROM pm1.g2" }, // $NON-NLS-1$ //$NON-NLS-2$
SHOULD_SUCCEED);
checkNodeTypes(plan, new int[] { // Access
2, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
1, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
checkNodeTypes(plan, new int[] { 1 }, new Class[] { EnhancedSortMergeJoinStrategy.class });
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestRuleMergeVirtual method testSimpleMergeGroupBy2.
/**
* Same as above but all required symbols are selected
*/
@Test
public void testSimpleMergeGroupBy2() {
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
"SELECT x, e1 FROM (SELECT distinct e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z", metadata, null, TestAggregatePushdown.getAggregatesFinder(), new String[] { "SELECT DISTINCT MAX(e2) AS x, e1 FROM pm1.g1 GROUP BY e1" }, // $NON-NLS-1$
TestOptimizer.SHOULD_SUCCEED);
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestRuleMergeVirtual method testViewPreservationWithGroupByExpression.
/**
* Note that the merge is not performed since it would create an expression in the group by clause
*/
@Test
public void testViewPreservationWithGroupByExpression() throws Exception {
String sql = // $NON-NLS-1$
"SELECT gbl_date " + // $NON-NLS-1$
"FROM " + // $NON-NLS-1$
"(SELECT a.intkey as x, convert(a.TimestampValue, date) AS gbl_date, b.intkey as y " + // $NON-NLS-1$
"FROM bqt1.smalla a INNER JOIN bqt1.smallb b on a.stringkey=b.stringkey) as z " + // $NON-NLS-1$
"GROUP BY gbl_date";
// Create capabilities
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
// $NON-NLS-1$
caps.setFunctionSupport("convert", true);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
// Plan query
ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, null, capFinder, // $NON-NLS-1$
new String[] { "SELECT v_0.c_0 FROM (SELECT convert(g_0.TimestampValue, date) AS c_0 FROM BQT1.SmallA AS g_0, BQT1.SmallB AS g_1 WHERE g_0.StringKey = g_1.StringKey) AS v_0 GROUP BY v_0.c_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestSubqueryPushdown method testDontPushSubqueryBelowVirtual.
/**
* Same as above, but using a correlated variable based on an aggregate
* @throws Exception
*/
@Test
public void testDontPushSubqueryBelowVirtual() throws Exception {
// $NON-NLS-1$
String sql = "select g3.e1 from (select e1, max(e2) y from pm1.g1 group by e1) x, pm1.g3 where exists (select e1 from pm1.g2 where x.y = e1)";
// Create capabilities
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
caps.setCapabilitySupport(Capability.CRITERIA_EXISTS, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
// Plan query
ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, null, capFinder, new String[] { // $NON-NLS-1$
"SELECT g_0.e1 FROM pm1.g3 AS g_0", // $NON-NLS-1$
"SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
2, // DependentAccess
0, // DependentSelect
1, // DependentProject
0, // DupRemove
0, // Grouping
1, // NestedLoopJoinStrategy
1, // MergeJoinStrategy
0, // Null
0, // PlanExecution
0, // Project
2, // Select
0, // Sort
0, // UnionAll
0 });
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestValidator method testValidateDynamicCommandWithNonTempGroup_InModeler.
@Test
public void testValidateDynamicCommandWithNonTempGroup_InModeler() throws Exception {
// SQL is same as pm1.vsp36() in example1
// $NON-NLS-1$
String sql = "CREATE VIRTUAL PROCEDURE BEGIN execute string 'select ' || '1' as X integer into pm1.g3; END";
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
// Validate
// $NON-NLS-1$
ValidatorReport report = helpValidateInModeler("pm1.vsp36", sql, metadata);
assertEquals(1, report.getItems().size());
// $NON-NLS-1$
assertEquals("Wrong number of elements being SELECTed INTO the target table. Expected 4 elements, but was 1.", report.toString());
}
Aggregations