use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testAllJoinsInSingleClause.
@Test
public void testAllJoinsInSingleClause() throws Exception {
ProcessorPlan plan = helpPlan(// $NON-NLS-1$
"select pm1.g1.e1 FROM pm1.g1 join (pm1.g2 right outer join pm1.g3 on pm1.g2.e1=pm1.g3.e1) on pm1.g1.e1=pm1.g3.e1", // $NON-NLS-1$
example1(), new String[] { // $NON-NLS-1$
"SELECT pm1.g1.e1 FROM pm1.g1", // $NON-NLS-1$
"SELECT pm1.g2.e1 FROM pm1.g2", "SELECT pm1.g3.e1 FROM pm1.g3" }, new DefaultCapabilitiesFinder(), // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
checkNodeTypes(plan, new int[] { // Access
3, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
2, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testManyJoinsGreedy.
@Test
public void testManyJoinsGreedy() throws Exception {
TransformationMetadata tm = example1();
RealMetadataFactory.setCardinality("pm1.g5", 1000000, tm);
RealMetadataFactory.setCardinality("pm1.g4", 1000000, tm);
RealMetadataFactory.setCardinality("pm1.g1", 10000000, tm);
RealMetadataFactory.setCardinality("pm1.g8", 100, tm);
RealMetadataFactory.setCardinality("pm1.g3", 10000, tm);
RealMetadataFactory.setCardinality("pm1.g6", 100000, tm);
ProcessorPlan plan = helpPlan("SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2, pm1.g3, pm1.g4, pm1.g5, pm1.g6, pm1.g7, pm1.g8 " + // $NON-NLS-1$
"WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g2.e1 = pm1.g3.e1 AND pm1.g3.e1 = pm1.g4.e1 AND pm1.g4.e1 = pm1.g5.e1 AND pm1.g5.e1=pm1.g6.e1 AND pm1.g6.e1=pm1.g7.e1 AND pm1.g7.e1=pm1.g8.e1", tm, new String[] { // $NON-NLS-1$
"SELECT pm1.g1.e1 FROM pm1.g1", // $NON-NLS-1$
"SELECT pm1.g2.e1 FROM pm1.g2", // $NON-NLS-1$
"SELECT pm1.g3.e1 FROM pm1.g3", // $NON-NLS-1$
"SELECT pm1.g4.e1 FROM pm1.g4", // $NON-NLS-1$
"SELECT pm1.g5.e1 FROM pm1.g5", // $NON-NLS-1$
"SELECT pm1.g6.e1 FROM pm1.g6", // $NON-NLS-1$
"SELECT pm1.g7.e1 FROM pm1.g7", // $NON-NLS-1$
"SELECT pm1.g8.e1 FROM pm1.g8" }, new DefaultCapabilitiesFinder(), // $NON-NLS-1$
ComparisonMode.CORRECTED_COMMAND_STRING);
RelationalPlan rp = (RelationalPlan) plan;
// g1 should be last
assertEquals("[pm1.g1.e1]", ((JoinNode) rp.getRootNode().getChildren()[0]).getRightExpressions().toString());
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testUnaliased.
@Test
public void testUnaliased() throws Exception {
// $NON-NLS-1$
String sql = "SELECT x.count + 1 FROM agg x";
TransformationMetadata metadata = RealMetadataFactory.fromDDL("create foreign table smalla (intkey integer); create view agg (count integer) as select intkey from smalla order by intkey limit 1", "x", "y");
BasicSourceCapabilities bsc = TestAggregatePushdown.getAggregateCapabilities();
bsc.setFunctionSupport("+", true);
TestOptimizer.helpPlan(sql, metadata, new String[] { "SELECT (v_0.c_0 + 1) FROM (SELECT g_0.intkey AS c_0 FROM y.smalla AS g_0 ORDER BY c_0 LIMIT 1) AS v_0" }, new DefaultCapabilitiesFinder(bsc), ComparisonMode.EXACT_COMMAND_STRING);
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testLikeEscapeRestriction.
@Test
public void testLikeEscapeRestriction() throws Exception {
// $NON-NLS-1$
String sql = "SELECT e2 FROM pm1.g1 where e1 like 'a%b' escape '!'";
BasicSourceCapabilities bsc = getTypicalCapabilities();
bsc.setSourceProperty(Capability.REQUIRED_LIKE_ESCAPE, '\\');
TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), new String[] { "SELECT g_0.e2 FROM pm1.g1 AS g_0 WHERE g_0.e1 LIKE 'a%b'" }, new DefaultCapabilitiesFinder(bsc), ComparisonMode.EXACT_COMMAND_STRING);
// $NON-NLS-1$
sql = "SELECT e2 FROM pm1.g1 where e1 like '!_a%b' escape '!'";
// TODO - when possible this should modify the match pattern to use the required escape
bsc.setSourceProperty(Capability.REQUIRED_LIKE_ESCAPE, '\\');
TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), new String[] { "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0" }, new DefaultCapabilitiesFinder(bsc), ComparisonMode.EXACT_COMMAND_STRING);
// $NON-NLS-1$
sql = "SELECT e2 FROM pm1.g1 where e1 like '\\_a%b' escape '\\'";
bsc.setSourceProperty(Capability.REQUIRED_LIKE_ESCAPE, '\\');
TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), new String[] { "SELECT g_0.e2 FROM pm1.g1 AS g_0 WHERE g_0.e1 LIKE '\\_a%b' ESCAPE '\\'" }, new DefaultCapabilitiesFinder(bsc), ComparisonMode.EXACT_COMMAND_STRING);
}
use of org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testCopyCriteriaWithTransitivePushdown3.
@Test
public void testCopyCriteriaWithTransitivePushdown3() throws TeiidComponentException, TeiidProcessingException {
BasicSourceCapabilities caps = getTypicalCapabilities();
caps.setFunctionSupport(SourceSystemFunctions.CONVERT, true);
ProcessorPlan plan = helpPlan(// $NON-NLS-1$
"select pm1.g1.e1 from pm1.g1, pm1.g2, pm1.g3 where pm1.g1.e1 = pm1.g2.e1 and pm1.g1.e1 = pm1.g3.e2 and pm1.g3.e2 = pm1.g2.e1", // $NON-NLS-1$
RealMetadataFactory.example1Cached(), new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g3 AS g_2 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = convert(g_2.e2, string)) AND (convert(g_2.e2, string) = g_1.e1)" }, new DefaultCapabilitiesFinder(caps), // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
checkNodeTypes(plan, FULL_PUSHDOWN);
}
Aggregations