use of org.teiid.query.processor.relational.RelationalPlan in project teiid by teiid.
the class TestSortOptimization method testProjectionRaisingWithComplexOrdering1.
@Test
public void testProjectionRaisingWithComplexOrdering1() {
// $NON-NLS-1$
String sql = "select e1 || 1 as a, e2 / 2 from pm1.g1 as x order by a, e2 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, c_1 LIMIT 2" }, // $NON-NLS-1$
TestOptimizer.SHOULD_SUCCEED);
assertTrue(plan.getRootNode() instanceof ProjectNode);
HardcodedDataManager hdm = new HardcodedDataManager();
hdm.addData("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, c_1 LIMIT 2", Arrays.asList("c1", 2), Arrays.asList("d1", 3));
TestProcessor.helpProcess(plan, hdm, new List<?>[] { Arrays.asList("c1", 1), Arrays.asList("d1", 1) });
}
use of org.teiid.query.processor.relational.RelationalPlan in project teiid by teiid.
the class TestCalculateCostUtil method helpTestQuery.
private void helpTestQuery(float cost, String query, String[] expected) throws TeiidComponentException, TeiidProcessingException {
// $NON-NLS-1$ //$NON-NLS-2$
RelationalPlan plan = (RelationalPlan) TestOptimizer.helpPlan(query, TestVirtualDepJoin.exampleVirtualDepJoin(), expected, ComparisonMode.EXACT_COMMAND_STRING);
assertEquals(cost, plan.getRootNode().getEstimateNodeCardinality());
}
use of org.teiid.query.processor.relational.RelationalPlan in project teiid by teiid.
the class TestJoinOptimization method testOuterJoinRemoval.
@Test
public void testOuterJoinRemoval() throws Exception {
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, false);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, false);
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
"SELECT * from pm1.g1 inner join (pm1.g2 left outer join pm1.g3 on pm1.g2.e1=pm1.g3.e1) on pm1.g1.e1=pm1.g3.e1", RealMetadataFactory.example1Cached(), new String[] { "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm1.g2 AS g_0 ORDER BY c_0", "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm1.g1 AS g_0 ORDER BY c_0", "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm1.g3 AS g_0 ORDER BY c_0" }, new DefaultCapabilitiesFinder(caps), // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
RelationalNode node = ((RelationalPlan) plan).getRootNode().getChildren()[0];
assertTrue(node instanceof JoinNode);
node = node.getChildren()[0];
assertTrue(node instanceof JoinNode);
assertEquals(JoinType.JOIN_INNER, ((JoinNode) node).getJoinType());
}
use of org.teiid.query.processor.relational.RelationalPlan in project teiid by teiid.
the class TestMaterialization method testDefaultMaterializationWithPK.
@Test
public void testDefaultMaterializationWithPK() throws Exception {
// $NON-NLS-1$
String userSql = "SELECT * from vgroup3 where x = 'foo'";
TransformationMetadata metadata = RealMetadataFactory.exampleMaterializedView();
AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
Command command = helpGetCommand(userSql, metadata, null);
CommandContext cc = new CommandContext();
GlobalTableStoreImpl gts = new GlobalTableStoreImpl(null, metadata.getVdbMetaData(), metadata);
cc.setGlobalTableStore(gts);
RelationalPlan plan = (RelationalPlan) TestOptimizer.getPlan(command, metadata, getGenericFinder(), analysis, true, cc);
assertEquals(1f, plan.getRootNode().getEstimateNodeCardinality());
TestOptimizer.checkAtomicQueries(new String[] { "SELECT #MAT_MATVIEW.VGROUP3.x, #MAT_MATVIEW.VGROUP3.y FROM #MAT_MATVIEW.VGROUP3 WHERE #MAT_MATVIEW.VGROUP3.x = 'foo'" }, plan);
Collection<Annotation> annotations = analysis.getAnnotations();
// $NON-NLS-1$
assertNotNull("Expected annotations but got none", annotations);
// $NON-NLS-1$
assertEquals("Expected one annotation", 1, annotations.size());
// $NON-NLS-1$
assertEquals("Expected catagory mat view", annotations.iterator().next().getCategory(), Annotation.MATERIALIZED_VIEW);
}
use of org.teiid.query.processor.relational.RelationalPlan in project teiid by teiid.
the class TestCalculateCostUtil method testLimitWithUnknownChildCardinality.
@Test
public void testLimitWithUnknownChildCardinality() throws Exception {
// $NON-NLS-1$
String query = "select e1 from pm1.g1 limit 2";
// $NON-NLS-1$
RelationalPlan plan = (RelationalPlan) TestOptimizer.helpPlan(query, RealMetadataFactory.example1Cached(), new String[] { "SELECT e1 FROM pm1.g1" });
assertEquals(new Float(2), plan.getRootNode().getEstimateNodeCardinality());
}
Aggregations