use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestOptimizer method testPushFunctionInJoin2.
@Test
public void testPushFunctionInJoin2() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
// $NON-NLS-1$
caps.setFunctionSupport("convert", true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
// Add join capability to pm1
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(// $NON-NLS-1$
"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2, pm1.g3 WHERE pm1.g1.e1 = convert(pm1.g2.e2, string) AND pm1.g1.e1 = concat(pm1.g3.e1, 'a') AND upper(pm1.g1.e1) = 'X'", metadata, null, capFinder, new String[] { // $NON-NLS-1$
"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE (pm1.g1.e1 = convert(pm1.g2.e2, string)) AND (ucase(pm1.g1.e1) = 'X') AND (ucase(convert(pm1.g2.e2, string)) = 'X')", // $NON-NLS-1$
"SELECT pm1.g3.e1 FROM pm1.g3" }, 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 testPushFunctionInCriteria1.
@Test
public void testPushFunctionInCriteria1() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
// Add join capability to pm1
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(// $NON-NLS-1$
"SELECT e1 FROM pm1.g1 WHERE upper(e1) = 'X'", metadata, null, capFinder, // $NON-NLS-1$
new String[] { "SELECT e1 FROM pm1.g1 WHERE ucase(e1) = 'X'" }, SHOULD_SUCCEED);
checkNodeTypes(plan, FULL_PUSHDOWN);
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestOptimizer method testCase3832.
/**
* Ensures that order by expressions are not repeated when multiple criteria span a merge join
*/
@Test
public void testCase3832() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
// $NON-NLS-1$
caps.setFunctionSupport("concat", true);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
// $NON-NLS-1$
capFinder.addCapabilities("BQT2", caps);
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
// $NON-NLS-1$
String sql = "select bqt1.smalla.intkey from bqt1.smalla, bqt2.smalla, bqt2.smallb where bqt1.smalla.intkey = bqt2.smalla.intkey and bqt1.smalla.intkey = bqt2.smallb.intkey and bqt2.smalla.stringkey = bqt2.smallb.stringkey";
helpPlan(sql, metadata, null, capFinder, new String[] { "SELECT BQT2.SmallB.IntKey, BQT2.SmallA.IntKey FROM BQT2.SmallA, BQT2.SmallB WHERE BQT2.SmallA.StringKey = BQT2.SmallB.StringKey ORDER BY BQT2.SmallB.IntKey, BQT2.SmallA.IntKey", // $NON-NLS-1$
"SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA ORDER BY BQT1.SmallA.IntKey" }, ComparisonMode.EXACT_COMMAND_STRING);
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestOptimizer method testCase2589v.
/**
* Same sql as testCase2589, but the model doesn't support outer joins, so
* case 2589 optimization shouldn't happen.
*/
@Test
public void testCase2589v() {
String sql = // $NON-NLS-1$
"SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + // $NON-NLS-1$
"VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey";
String[] expected = new String[] { // $NON-NLS-1$
"SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA", // $NON-NLS-1$
"SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA WHERE StringNum = '10'" };
// Plan query
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, false);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, false);
// $NON-NLS-1$
caps.setFunctionSupport("concat", true);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, expected, 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 });
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestOptimizer method testPushFunctionInSelectWithOrderBy2.
/**
* defect 13336
*/
@Test
public void testPushFunctionInSelectWithOrderBy2() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
// Add join capability to pm1
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(// $NON-NLS-1$
"SELECT e1, x FROM (SELECT e1, lower(e1) AS x FROM pm1.g1 WHERE upper(e1) = 'X') AS z ORDER BY x", metadata, null, capFinder, // $NON-NLS-1$
new String[] { "SELECT e1, lcase(e1) AS EXPR FROM pm1.g1 WHERE ucase(e1) = 'X' ORDER BY EXPR" }, SHOULD_SUCCEED);
checkNodeTypes(plan, FULL_PUSHDOWN);
}
Aggregations