use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestCallableStatement method testNoReturnParameter.
@Test
public void testNoReturnParameter() throws Exception {
// $NON-NLS-1$
String sql = "{call pm4.spTest9(?)}";
List values = new ArrayList();
values.add(1);
List[] expected = new List[1];
expected[0] = Arrays.asList(1);
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("EXEC pm4.spTest9(1)", expected);
helpProcess(sql, values, expected, dataManager);
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestAggregatePushdown method testOuterJoinPushdown2.
@Test
public void testOuterJoinPushdown2() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = getAggregateCapabilities();
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
// $NON-NLS-1$
capFinder.addCapabilities("pm2", caps);
// $NON-NLS-1$
String sql = "SELECT x.e2, y.e1, count(*) from pm1.g1 x full outer join pm2.g1 y on x.e3 = y.e3 group by x.e2, y.e1";
ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), null, capFinder, new String[] { "SELECT g_0.e3, g_0.e2, COUNT(*) FROM pm1.g1 AS g_0 GROUP BY g_0.e3, g_0.e2", "SELECT g_0.e3, g_0.e1 FROM pm2.g1 AS g_0" }, // $NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
2, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
1, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
1, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
HardcodedDataManager hdm = new HardcodedDataManager();
hdm.addData("SELECT g_0.e3, g_0.e2, COUNT(*) FROM pm1.g1 AS g_0 GROUP BY g_0.e3, g_0.e2", Arrays.asList(true, 1, 3), Arrays.asList(true, 2, 2), Arrays.asList(null, 3, 4));
hdm.addData("SELECT g_0.e3, g_0.e1 FROM pm2.g1 AS g_0", Arrays.asList(false, "a"), Arrays.asList(true, "b"), Arrays.asList(true, "b"));
TestProcessor.helpProcess(plan, hdm, new List[] { Arrays.asList(null, "a", 1), Arrays.asList(1, "b", 6), Arrays.asList(2, "b", 4), Arrays.asList(3, null, 4) });
// $NON-NLS-1$
sql = "SELECT x.e2, y.e1, count(1) from pm1.g1 x full outer join pm2.g1 y on x.e3 = y.e3 group by x.e2, y.e1";
plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), null, capFinder, new String[] { "SELECT g_0.e3, g_0.e2, COUNT(1) FROM pm1.g1 AS g_0 GROUP BY g_0.e3, g_0.e2", "SELECT g_0.e3, g_0.e1 FROM pm2.g1 AS g_0" }, // $NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
hdm.addData("SELECT g_0.e3, g_0.e2, COUNT(1) FROM pm1.g1 AS g_0 GROUP BY g_0.e3, g_0.e2", Arrays.asList(true, 1, 3), Arrays.asList(true, 2, 2), Arrays.asList(null, 3, 4));
TestProcessor.helpProcess(plan, hdm, new List[] { Arrays.asList(null, "a", 1), Arrays.asList(1, "b", 6), Arrays.asList(2, "b", 4), Arrays.asList(3, null, 4) });
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestJoinOptimization method testCrossSourceOuterWithOffset.
@Test
public void testCrossSourceOuterWithOffset() throws Exception {
String sql = "SELECT pm1.g1.e1, pm2.g1.e2 from pm1.g1 left outer join pm2.g1 on pm1.g1.e1 = pm2.g1.e1 ORDER BY pm1.g1.e1 OFFSET 1 ROWS";
BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();
bsc.setCapabilitySupport(Capability.ROW_LIMIT, true);
bsc.setCapabilitySupport(Capability.ROW_OFFSET, true);
DefaultCapabilitiesFinder capFinder = new DefaultCapabilitiesFinder(bsc);
ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), null, capFinder, new String[] { "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm2.g1 AS g_0 ORDER BY c_0", "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0" }, ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager hdm = new HardcodedDataManager();
hdm.addData("SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0", Arrays.asList("a"), Arrays.asList("b"));
hdm.addData("SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm2.g1 AS g_0 ORDER BY c_0", Arrays.asList("a", 1), Arrays.asList("b", 2));
helpProcess(plan, createCommandContext(), hdm, new List[] { Arrays.asList("b", 2) });
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestJoinOptimization method testOutputColumnsWithMergeJoinAndNonPushedSelect1.
@Test
public void testOutputColumnsWithMergeJoinAndNonPushedSelect1() 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.intkey = case when bqt1.smalla.intkey = 1 then 2 else 3 end) where right(bqt1.smalla.stringkey, 1) = 'a'";
BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();
bsc.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
bsc.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
// Plan query
ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), new String[] { "SELECT g_0.IntKey FROM BQT2.SmallA AS g_0", "SELECT g_0.StringKey, g_0.IntKey FROM BQT1.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("aa", 1));
hdm.addData("SELECT g_0.IntKey FROM BQT2.SmallA AS g_0", Arrays.asList(1));
TestProcessor.helpProcess(plan, hdm, new List<?>[] {});
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestJoinOptimization method testLateralProcedurePushdown.
@Test
public void testLateralProcedurePushdown() throws Exception {
String sql = "select smallb.intkey, x.stringkey, x.intkey " + // $NON-NLS-1$
"from smallb left outer join lateral (exec spTest5(smallb.intkey)) as x on (true)";
BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();
bsc.setCapabilitySupport(Capability.ROW_LIMIT, true);
bsc.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
bsc.setCapabilitySupport(Capability.QUERY_FROM_JOIN_LATERAL, true);
bsc.setCapabilitySupport(Capability.QUERY_FROM_PROCEDURE_TABLE, true);
bsc.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
bsc.setCapabilitySupport(Capability.QUERY_ONLY_FROM_JOIN_LATERAL_PROCEDURE, true);
TransformationMetadata metadata = RealMetadataFactory.fromDDL("create foreign table smallb (intkey integer, stringkey string); " + "create foreign procedure spTest5 (param integer) returns table(stringkey string, intkey integer)", "x", "y");
ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, new String[] { "SELECT g_0.intkey, v_0.stringkey, v_0.intkey FROM y.smallb AS g_0 LEFT OUTER JOIN LATERAL(EXEC spTest5(g_0.intkey)) AS v_0 ON 1 = 1" }, new DefaultCapabilitiesFinder(bsc), // $NON-NLS-1$ //$NON-NLS-2$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager hdm = new HardcodedDataManager(metadata);
hdm.addData("SELECT g_0.intkey, v_0.stringkey, v_0.intkey FROM smallb AS g_0 LEFT OUTER JOIN LATERAL (EXEC spTest5(g_0.intkey)) AS v_0 ON 1 = 1", Arrays.asList(1, "2", 1));
TestProcessor.helpProcess(plan, hdm, new List<?>[] { Arrays.asList(1, "2", 1) });
bsc.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
// with an extra inline view, should result in same plan - but is not currently as we can't remove the intermediate view without
// a lot of work
sql = "SELECT g_0.intkey, v_1.c_0, v_1.c_1 FROM y.smallb AS g_0 LEFT OUTER JOIN LATERAL(SELECT v_0.stringkey AS c_0, v_0.intkey AS c_1 FROM (EXEC spTest5(g_0.intkey)) AS v_0 limit 1) AS v_1 ON 1 = 1";
plan = TestOptimizer.helpPlan(sql, metadata, new String[] { "SELECT g_0.intkey FROM y.smallb AS g_0", "EXEC spTest5(g_0.intkey)" }, new DefaultCapabilitiesFinder(bsc), // $NON-NLS-1$ //$NON-NLS-2$
ComparisonMode.EXACT_COMMAND_STRING);
hdm.addData("SELECT g_0.intkey FROM smallb AS g_0", Arrays.asList(1));
hdm.addData("EXEC spTest5(1)", Arrays.asList("2", 1));
TestProcessor.helpProcess(plan, hdm, new List<?>[] { Arrays.asList(1, "2", 1) });
}
Aggregations