use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestProcedureProcessor method testDepJoinFullProcessing.
@Test
public void testDepJoinFullProcessing() throws Exception {
String sql = " BEGIN" + "\n create local temporary table ssid_version (sysplex varchar, lpar varchar, ssid varchar, version varchar);" + "\n insert into ssid_version(sysplex, lpar, ssid, version) values ('plex1', 'ca11', 'd91a', 'v5');" + "\n insert into ssid_version(sysplex, lpar, ssid, version) values ('plex1', 'ca11', 'd91b', 'v6');" + "\n create local temporary table table_spaces_v5 (sysplex varchar, lpar varchar, ssid varchar, table_space_id varchar);" + "\n insert into table_spaces_v5 (sysplex, lpar, ssid, table_space_id) values ('plex1', 'ca11', 'd91a', 'ts1');" + "\n create local temporary table table_spaces_v6 (sysplex varchar, lpar varchar, ssid varchar, table_space_id varchar);" + "\n insert into table_spaces_v6 (sysplex, lpar, ssid, table_space_id) values ('plex1', 'ca11', 'd91b', 'ts2');" + "\n select table_space_id from ( select * from (select v.sysplex, v.lpar, v.ssid, t.table_space_id from ssid_version v join table_spaces_v5 t on t.sysplex=v.sysplex and t.lpar=v.lpar and t.ssid=v.ssid option makedep table_spaces_v5) t" + " union all select * from (select v.sysplex, v.lpar, v.ssid, t.table_space_id from ssid_version v join table_spaces_v6 t on t.sysplex=v.sysplex and t.lpar=v.lpar and t.ssid=v.ssid option makedep table_spaces_v6) t" + " ) t where ssid='d91a';" + // + " raise e.exception;"
"\n END";
TransformationMetadata tm = RealMetadataFactory.example1Cached();
ProcessorPlan plan = getProcedurePlan(sql, tm);
HardcodedDataManager dataManager = new HardcodedDataManager(tm);
dataManager.addData("SELECT g1.e1 FROM g1", new List<?>[] { Arrays.asList("a") });
// $NON-NLS-1$
List[] expected = new List[] { Arrays.asList("ts1") };
helpTestProcess(plan, expected, dataManager, tm);
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestProcedureProcessor method testReturnable1.
/**
* Should return the first results
*/
@Test
public void testReturnable1() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.example1();
addProc(metadata, "sq2", // $NON-NLS-1$ //$NON-NLS-2$
"CREATE VIRTUAL PROCEDURE BEGIN\n" + "SELECT e1, e2 FROM pm1.g1; select e1, e2 from pm1.g2 without return; END", new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER }, new String[] { "in" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
// $NON-NLS-1$
String userUpdateStr = "EXEC pm1.sq2('First')";
HardcodedDataManager dataMgr = new HardcodedDataManager();
dataMgr.addData("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1", new List<?>[0]);
dataMgr.addData("SELECT pm1.g2.e1, pm1.g2.e2 FROM pm1.g2", new List<?>[] { Arrays.asList("a", 1) });
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
List[] expected = new List<?>[0];
helpTestProcess(plan, expected, dataMgr, metadata);
assertEquals(6, dataMgr.getCommandHistory().size());
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestProcedureProcessor method testDynamicInsert1.
@Test(expected = TeiidProcessingException.class)
public void testDynamicInsert1() throws Exception {
// $NON-NLS-1$
String sql = "exec p1(1)";
TransformationMetadata tm = RealMetadataFactory.fromDDL("create virtual procedure p1(a long) returns (res long) as " + "begin create local temporary table t (x string); execute immediate 'insert into t select ''a''' as res long; end;", "x", "y");
ProcessorPlan plan = getProcedurePlan(sql, tm);
HardcodedDataManager dataManager = new HardcodedDataManager(tm);
// $NON-NLS-1$
List[] expected = new List[] {};
helpTestProcess(plan, expected, dataManager, tm);
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestProcedureProcessor method testDyanmicAnonBlockWithReturn.
@Test
public void testDyanmicAnonBlockWithReturn() throws Exception {
// $NON-NLS-1$
String sql = "begin execute immediate 'begin select 1; select 1, 2; end'; end";
TransformationMetadata tm = RealMetadataFactory.example1Cached();
ProcessorPlan plan = getProcedurePlan(sql, tm);
HardcodedDataManager dataManager = new HardcodedDataManager(tm);
// $NON-NLS-1$
List[] expected = new List[] {};
helpTestProcess(plan, expected, dataManager, tm);
// $NON-NLS-1$
sql = "begin execute immediate 'begin select 1; select 1, 2; end' as y string; end";
tm = RealMetadataFactory.example1Cached();
plan = getProcedurePlan(sql, tm);
try {
helpTestProcess(plan, expected, dataManager, tm);
fail();
} catch (QueryProcessingException e) {
}
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestProcedureProcessor method testOmitDefault.
@Test
public void testOmitDefault() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.fromDDL("CREATE foreign procedure f1(x string not null options (\"teiid_rel:default_handling\" 'omit')) RETURNS string;", "x", "y");
ProcessorPlan plan = helpGetPlan("exec f1()", metadata);
CommandContext cc = TestProcessor.createCommandContext();
cc.setMetadata(metadata);
HardcodedDataManager hdm = new HardcodedDataManager(metadata);
hdm.addData("EXEC f1()", Arrays.asList("a"));
helpProcess(plan, cc, hdm, new List[] { Arrays.asList("a") });
}
Aggregations