use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestOptimizer method testPushSelfJoin2.
@Test
public void testPushSelfJoin2() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
// Add join capability to pm1
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(// $NON-NLS-1$
"SELECT a.e1 AS x, concat(a.e2, b.e2) AS y FROM pm1.g1 a, pm1.g1 b WHERE a.e1 = b.e1", metadata, null, capFinder, // $NON-NLS-1$
new String[] { "SELECT a.e1, a.e2, b.e2 FROM pm1.g1 AS a, pm1.g1 AS b WHERE a.e1 = b.e1" }, SHOULD_SUCCEED);
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
0, // Sort
0, // UnionAll
0 });
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestOptimizer method testDefect14510LookupFunction2.
/**
* defect 14510
*/
@Test
public void testDefect14510LookupFunction2() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQT();
// $NON-NLS-1$
RealMetadataFactory.setCardinality("bqt1.mediumb", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata);
// $NON-NLS-1$
RealMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata);
ProcessorPlan plan = helpPlan(// $NON-NLS-1$
"SELECT BQT1.SmallA.IntKey, BQT1.MediumB.IntKey FROM BQT1.SmallA LEFT OUTER JOIN BQT1.MediumB ON BQT1.SmallA.IntKey = lookup('BQT1.MediumB', 'IntKey', 'StringKey', BQT1.MediumB.StringKey)", metadata, null, capFinder, // $NON-NLS-1$ //$NON-NLS-2$
new String[] { "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA", "SELECT BQT1.MediumB.StringKey, BQT1.MediumB.IntKey FROM BQT1.MediumB" }, 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
2, // Select
1, // Sort
0, // UnionAll
0 });
}
use of org.teiid.query.metadata.QueryMetadataInterface 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.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestOptimizer method testCase3778.
/*
* Set criteria was not getting pushed down correctly when there was a self-join
* of a virtual table containing a join in it's transformation. All virtual
* models use the same physical model pm1.
*/
@Test
public void testCase3778() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
BasicSourceCapabilities caps = getTypicalCapabilities();
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
ProcessorPlan plan = helpPlan(// $NON-NLS-1$
"select a.e1, b.e1 from vm2.g1 a, vm2.g1 b where a.e1 = b.e1 and a.e2 in /*+ no_unnest */ (select e2 from vm1.g1)", metadata, null, capFinder, new String[] { "SELECT g_0.e1, g_2.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g1 AS g_2, pm1.g2 AS g_3 WHERE (g_2.e2 = g_3.e2) AND (g_0.e2 = g_1.e2) AND (g_0.e1 = g_2.e1) AND (g_0.e2 IN /*+ NO_UNNEST */ (SELECT g_4.e2 FROM pm1.g1 AS g_4))" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
checkNodeTypes(plan, FULL_PUSHDOWN);
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestAggregatePushdown method testCase5724.
/**
* Test to ensure count(*) isn't mistakenly pushed to either side
*/
@Test
public void testCase5724() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = getAggregateCapabilities();
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
// $NON-NLS-1$
capFinder.addCapabilities("BQT2", caps);
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
ProcessorPlan plan = TestOptimizer.helpPlan(// $NON-NLS-1$
"select count(*), a.intnum from bqt1.smalla as a, bqt2.smallb as b where a.intkey = b.intkey group by a.intnum", metadata, null, capFinder, new String[] { "SELECT g_0.IntKey, g_0.IntNum, COUNT(*) FROM BQT1.SmallA AS g_0 GROUP BY g_0.IntKey, g_0.IntNum", // $NON-NLS-1$ //$NON-NLS-2$
"SELECT g_0.IntKey FROM BQT2.SmallB AS g_0" }, true);
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