use of org.teiid.query.processor.relational.RelationalPlan in project teiid by teiid.
the class TestRuleRaiseNull method testRaiseNullWithUnionAndAliases.
@Test
public void testRaiseNullWithUnionAndAliases() {
// $NON-NLS-1$
String sql = "select pm1.g1.e1 from pm1.g1, (select e1 from pm1.g1 where (1 = 0) union all select e1 as x from pm1.g2) x where pm1.g1.e1 <> x.e1";
RelationalPlan plan = (RelationalPlan) TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), // $NON-NLS-1$
new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e1 <> g_1.e1" });
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
use of org.teiid.query.processor.relational.RelationalPlan in project teiid by teiid.
the class TestSortOptimization method testProjectionRaisingWithLimit1.
@Test
public void testProjectionRaisingWithLimit1() {
// Create query
// $NON-NLS-1$
String sql = "select (select e1 from pm2.g1 where e2 = x.e2) as z from pm1.g1 as x order by z limit 2";
RelationalPlan plan = (RelationalPlan) helpPlan(sql, RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(), new String[] { "SELECT pm1.g1.e2 FROM pm1.g1" }, // $NON-NLS-1$
TestOptimizer.SHOULD_SUCCEED);
assertTrue(plan.getRootNode() instanceof LimitNode);
}
use of org.teiid.query.processor.relational.RelationalPlan in project teiid by teiid.
the class TestSortOptimization method testProjectionRaisingWithComplexOrdering.
@Test
public void testProjectionRaisingWithComplexOrdering() {
// $NON-NLS-1$
String sql = "select e1 || 1, e2 / 2 from pm1.g1 as x order by e1 || 1 limit 2";
BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();
bsc.setFunctionSupport(SourceSystemFunctions.CONCAT, true);
bsc.setCapabilitySupport(Capability.ROW_LIMIT, true);
CapabilitiesFinder finder = new DefaultCapabilitiesFinder(bsc);
RelationalPlan plan = (RelationalPlan) helpPlan(sql, RealMetadataFactory.example1Cached(), null, finder, new String[] { "SELECT concat(g_0.e1, '1') AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0 LIMIT 2" }, // $NON-NLS-1$
TestOptimizer.SHOULD_SUCCEED);
assertTrue(plan.getRootNode() instanceof ProjectNode);
}
use of org.teiid.query.processor.relational.RelationalPlan in project teiid by teiid.
the class TestRuleMergeVirtual method testSortAliasWithSameName.
@Test
public void testSortAliasWithSameName() throws Exception {
// $NON-NLS-1$
String sql = "select e1 from (select distinct pm1.g1.e1 as e1 from pm1.g1) x order by e1";
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
RelationalPlan plan = (RelationalPlan) TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, capFinder, // $NON-NLS-1$
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
SortNode node = (SortNode) plan.getRootNode();
// $NON-NLS-1$
assertTrue("Alias was not accounted for in sort node", node.getElements().get(0).equals(node.getSortElements().get(0).getSymbol()));
}
use of org.teiid.query.processor.relational.RelationalPlan in project teiid by teiid.
the class TestRuleMergeVirtual method testSortAliasWithSameNameUnion.
@Test
public void testSortAliasWithSameNameUnion() throws Exception {
// $NON-NLS-1$
String sql = "select e1 from (select distinct pm1.g1.e1 as e1 from pm1.g1) x union all select e1 from pm1.g2 order by e1";
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
RelationalPlan plan = (RelationalPlan) TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0", "SELECT g_0.e1 FROM pm1.g2 AS g_0" }, capFinder, // $NON-NLS-1$
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
SortNode node = (SortNode) plan.getRootNode();
// $NON-NLS-1$
assertTrue("Alias was not accounted for in sort node", node.getElements().get(0).equals(node.getSortElements().get(0).getSymbol()));
}
Aggregations