use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestSubqueryPushdown method testDeleteSubqueryCorrelatedCompensated.
@Test
public void testDeleteSubqueryCorrelatedCompensated() throws Exception {
BasicSourceCapabilities bsc = getTypicalCapabilities();
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
"delete FROM pm1.g1 x where e1 = 'a' and e3 = (select e3 from pm1.g2 where e2 < x.e2)", RealMetadataFactory.example4(), null, new DefaultCapabilitiesFinder(bsc), new String[] {}, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager hcdm = new HardcodedDataManager();
hcdm.addData("SELECT g_0.e3, g_0.e2, g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 = 'a'", Arrays.asList(true, 1, 'a'));
hcdm.addData("SELECT g_0.e3 FROM pm1.g2 AS g_0 WHERE g_0.e2 < 1", Arrays.asList(true));
hcdm.addData("DELETE FROM pm1.g1 WHERE pm1.g1.e1 = 'a'", Arrays.asList(1));
TestProcessor.helpProcess(plan, hcdm, null);
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestSubqueryPushdown method testAggNestedSubquery.
@Test
public void testAggNestedSubquery() throws Exception {
// $NON-NLS-1$
String sql = "SELECT g0.a, g0.b, (SELECT max((SELECT g2.a FROM m.z AS g2 WHERE g2.b = g1.a)) FROM m.y AS g1 WHERE g0.a = g1.b) FROM m.x AS g0";
TransformationMetadata metadata = RealMetadataFactory.fromDDL("create foreign table x (" + " a string, " + " b string, " + " primary key (a)" + ") options (updatable true);" + "create foreign table y (" + " a string, " + " b string, " + " primary key (a)" + ") options (updatable true);" + "create foreign table z (" + " a string, " + " b string, " + " primary key (a)" + ") options (updatable true);", "x", "m");
ProcessorPlan pp = TestProcessor.helpGetPlan(sql, metadata, TestOptimizer.getGenericFinder());
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT g_0.a, g_0.b FROM m.x AS g_0", Arrays.asList("a", "b"), Arrays.asList("a1", "b1"));
dataManager.addData("SELECT g_0.a FROM m.y AS g_0 WHERE g_0.b = 'a'", Arrays.asList("a"));
dataManager.addData("SELECT g_0.a FROM m.y AS g_0 WHERE g_0.b = 'a1'", Arrays.asList("b"));
dataManager.addData("SELECT g_0.a FROM m.z AS g_0 WHERE g_0.b = 'b'", Arrays.asList("b2"));
dataManager.addData("SELECT g_0.a FROM m.z AS g_0 WHERE g_0.b = 'a'", Arrays.asList("a2"));
TestProcessor.helpProcess(pp, dataManager, new List[] { Arrays.asList("a", "b", "a2"), Arrays.asList("a1", "b1", "b2") });
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestSubqueryPushdown method testCorrelatedOnly.
/**
* Shows the uncorrelated subquery is evaluated ahead of time
*/
@Test
public void testCorrelatedOnly() throws Exception {
BasicSourceCapabilities bsc = getTypicalCapabilities();
bsc.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
bsc.setCapabilitySupport(Capability.QUERY_SUBQUERIES_ONLY_CORRELATED, true);
bsc.setCapabilitySupport(Capability.CRITERIA_EXISTS, true);
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
"SELECT 1 FROM bqt1.smalla where EXISTS (SELECT 'Y' FROM bqt1.mediuma)", RealMetadataFactory.exampleBQTCached(), null, new DefaultCapabilitiesFinder(bsc), new String[] { "SELECT 1 FROM BQT1.SmallA AS g_0 WHERE EXISTS (SELECT 'Y' FROM BQT1.MediumA AS g_0)" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager hcdm = new HardcodedDataManager(false);
TestProcessor.helpProcess(plan, hcdm, null);
assertEquals("SELECT 'Y' FROM BQT1.MediumA AS g_0", hcdm.getCommandHistory().get(0).toString());
assertEquals("SELECT 1 FROM BQT1.SmallA AS g_0", hcdm.getCommandHistory().get(1).toString());
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestUnionPlanning method testImplicitPartionwiseStarJoinMinimalColumns.
@Test
public void testImplicitPartionwiseStarJoinMinimalColumns() throws Exception {
TransformationMetadata tm = partitionedStartSchema();
String sql = "select combined_fact.id, combined_dim1.val, combined_dim2.val 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_1.val, 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)", "SELECT g_0.id, g_1.val, 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)" }, ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT g_0.id, g_1.val, 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, "abc", "def"));
dataManager.addData("SELECT g_0.id, g_1.val, 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, "2abc", "2def"));
TestProcessor.helpProcess(plan, dataManager, new List[] { Arrays.asList(1, "abc", "def"), Arrays.asList(10, "2abc", "2def") });
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestUnionPlanning method testPreserveGroupingOverUnion.
// TODO: enhancement for ordering over a partition
@Test
public void testPreserveGroupingOverUnion() throws TeiidComponentException, TeiidProcessingException {
String sql = "select y.col2 from ( select x.col2, min(x.col1) as col1 from ( select 1 as col2, col1 from " + "(select 'a' as col1 UNION SELECT '' as col1) v1 union select 1 as col2, col1 from (select 'b' as col1 UNION SELECT '' as col1) v2) x group by x.col2 ) y";
TransformationMetadata tm = RealMetadataFactory.example1Cached();
ProcessorPlan plan = // $NON-NLS-1$
TestOptimizer.helpPlan(// $NON-NLS-1$
sql, // $NON-NLS-1$
tm, // $NON-NLS-1$
null, // $NON-NLS-1$
new DefaultCapabilitiesFinder(), new String[] {}, ComparisonMode.EXACT_COMMAND_STRING);
TestProcessor.helpProcess(plan, new HardcodedDataManager(), new List[] { Arrays.asList(1) });
}
Aggregations