use of org.teiid.query.processor.HardcodedDataManager 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.HardcodedDataManager in project teiid by teiid.
the class TestSubqueryPushdown method testNestedCorrelationInAggregate.
@Test
public void testNestedCorrelationInAggregate() throws Exception {
TransformationMetadata tm = RealMetadataFactory.fromDDL("CREATE foreign TABLE a (c1 integer, c2 integer); " + "CREATE foreign TABLE b (c3 integer, c4 integer); CREATE foreign TABLE c (c5 integer, c6 integer);", "x", "y");
String sql = "SELECT max((select c2 from (select * from b as x) as b where c3 = (select c5 from c as x where c6 = c1))) FROM a as x group by c1, c2";
BasicSourceCapabilities bsc = getTypicalCapabilities();
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
sql, tm, null, new DefaultCapabilitiesFinder(bsc), new String[] { "SELECT g_0.c1, g_0.c2 FROM y.a AS g_0" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager hdm = new HardcodedDataManager(tm);
hdm.addData("SELECT g_0.c1, g_0.c2 FROM a AS g_0", Arrays.asList(1, 2));
hdm.addData("SELECT g_0.c5 FROM c AS g_0 WHERE g_0.c6 = 1", Arrays.asList(1));
hdm.addData("SELECT 2 FROM b AS g_0 WHERE g_0.c3 = 1", Arrays.asList(2));
CommandContext cc = TestProcessor.createCommandContext();
cc.setMetadata(tm);
TestProcessor.helpProcess(plan, cc, hdm, new List[] { Arrays.asList(2) });
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestSubqueryPushdown method testPreEvaluationInAggregate.
@Test
public void testPreEvaluationInAggregate() throws Exception {
TransformationMetadata tm = RealMetadataFactory.fromDDL("x", new DDLHolder("my", "CREATE foreign TABLE test_b (b integer, c integer)"), new DDLHolder("pg", "CREATE foreign TABLE test_a (a integer, b integer); CREATE foreign TABLE test_only_pg (a integer, b integer);"));
String sql = "SELECT SUM(x.b - (SELECT a FROM pg.test_only_pg WHERE b = 1)) FROM my.test_b x INNER JOIN pg.test_a y ON x.b = y.b";
BasicSourceCapabilities bsc = getTypicalCapabilities();
bsc.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
bsc.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR_PROJECTION, true);
bsc.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
bsc.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
bsc.setFunctionSupport("-", true);
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
sql, tm, null, new DefaultCapabilitiesFinder(bsc), new String[] { "SELECT g_0.b AS c_0, SUM((g_0.b - (SELECT a FROM pg.test_only_pg WHERE b = 1 LIMIT 2))) AS c_1 FROM my.test_b AS g_0 GROUP BY g_0.b ORDER BY c_0", "SELECT g_0.b AS c_0 FROM pg.test_a AS g_0 ORDER BY c_0" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager hdm = new HardcodedDataManager(tm);
hdm.addData("SELECT g_0.a FROM test_only_pg AS g_0 WHERE g_0.b = 1", Arrays.asList(2));
hdm.addData("SELECT g_0.b AS c_0, SUM((g_0.b - 2)) AS c_1 FROM test_b AS g_0 GROUP BY g_0.b ORDER BY c_0", Arrays.asList(3, 1));
hdm.addData("SELECT g_0.b AS c_0 FROM test_a AS g_0 ORDER BY c_0", Arrays.asList(3));
CommandContext cc = TestProcessor.createCommandContext();
cc.setMetadata(tm);
TestProcessor.helpProcess(plan, cc, hdm, new List[] { Arrays.asList(Long.valueOf(1)) });
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestUnionPlanning method testImplictPartitionwiseStarJoin.
@Test
public void testImplictPartitionwiseStarJoin() throws Exception {
TransformationMetadata tm = partitionedStartSchema();
String sql = "select * from combined_fact, combined_dim1, combined_dim2 where combined_fact.dim_id1 = combined_dim1.id and combined_fact.dim_id2 = combined_dim2.id";
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
sql, // $NON-NLS-1$
tm, // $NON-NLS-1$
null, // $NON-NLS-1$
TestOptimizer.getGenericFinder(), new String[] { "SELECT g_0.id, g_0.dim_id1, g_0.dim_id2, g_1.id, g_1.val, g_2.id, g_2.val FROM source1.fact AS g_0, source1.dim1 AS g_1, source1.dim2 AS g_2 WHERE (g_0.dim_id1 = g_1.id) AND (g_0.dim_id2 = g_2.id)", "SELECT g_0.id, g_0.dim_id1, g_0.dim_id2, g_1.id, g_1.val, g_2.id, g_2.val FROM source2.fact AS g_0, source2.dim1 AS g_1, source2.dim2 AS g_2 WHERE (g_0.dim_id1 = g_1.id) AND (g_0.dim_id2 = g_2.id)" }, ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
2, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
0, // Null
0, // PlanExecution
0, // Project
0, // Select
0, // Sort
0, // UnionAll
1 });
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT g_0.id, g_0.dim_id1, g_0.dim_id2, g_1.id, g_1.val, g_2.id, g_2.val FROM source1.fact AS g_0, source1.dim1 AS g_1, source1.dim2 AS g_2 WHERE (g_0.dim_id1 = g_1.id) AND (g_0.dim_id2 = g_2.id)", Arrays.asList(1, 1, 1, 1, "abc", 1, "def"));
dataManager.addData("SELECT g_0.id, g_0.dim_id1, g_0.dim_id2, g_1.id, g_1.val, g_2.id, g_2.val FROM source2.fact AS g_0, source2.dim1 AS g_1, source2.dim2 AS g_2 WHERE (g_0.dim_id1 = g_1.id) AND (g_0.dim_id2 = g_2.id)", Arrays.asList(10, 10, 10, 10, "2abc", 10, "2def"));
TestProcessor.helpProcess(plan, dataManager, new List[] { Arrays.asList(1, 1, 1, 1, 1, "abc", 1, 1, "def", 1), Arrays.asList(10, 10, 10, 2, 10, "2abc", 2, 10, "2def", 2) });
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestJoinOptimization method testMergeJoinOrderNotPushed.
@Test
public void testMergeJoinOrderNotPushed() throws TeiidComponentException, TeiidProcessingException {
String sql = "select bqt1.smalla.intkey, bqt2.smalla.intkey " + // $NON-NLS-1$
"from bqt1.smalla inner join bqt2.smalla on (bqt2.smalla.stringkey = bqt1.smalla.stringkey)";
BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();
bsc.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
bsc.setSourceProperty(Capability.COLLATION_LOCALE, "nowhere");
// Plan query
ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), new String[] { "SELECT g_0.StringKey, g_0.IntKey FROM BQT1.SmallA AS g_0", "SELECT g_0.StringKey, g_0.IntKey FROM BQT2.SmallA AS g_0" }, new DefaultCapabilitiesFinder(bsc), // $NON-NLS-1$ //$NON-NLS-2$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager hdm = new HardcodedDataManager();
hdm.addData("SELECT g_0.StringKey, g_0.IntKey FROM BQT1.SmallA AS g_0", Arrays.asList("b", 1), Arrays.asList("a", 3));
hdm.addData("SELECT g_0.StringKey, g_0.IntKey FROM BQT2.SmallA AS g_0", Arrays.asList("c", 1), Arrays.asList("a", 2));
TestProcessor.helpProcess(plan, hdm, new List<?>[] { Arrays.asList(3, 2) });
}
Aggregations