use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestProcedureProcessor method testDynamicCommandRecursion.
@Test
public void testDynamicCommandRecursion() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.example1();
addProc(metadata, "sq2", // $NON-NLS-1$ //$NON-NLS-2$
"CREATE VIRTUAL PROCEDURE BEGIN\n" + "execute string 'EXEC pm1.sq2(''First'')' as e1 string, e2 integer; 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')";
FakeDataManager dataMgr = exampleDataManager(metadata);
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
helpTestProcessFailure(plan, dataMgr, "TEIID30168 Couldn't execute the dynamic SQL command \"EXECUTE IMMEDIATE 'EXEC pm1.sq2(''First'')' AS e1 string, e2 integer\" with the SQL statement \"EXEC pm1.sq2('First')\" due to: TEIID30347 There is a recursive invocation of group 'pm1.sq2'. Please correct the SQL.", // $NON-NLS-1$
metadata);
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestProcedureProcessor method testEvaluatableSelectWithOrderBy1.
@Test
public void testEvaluatableSelectWithOrderBy1() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.example1();
StringBuffer procedure = // $NON-NLS-1$
new StringBuffer("CREATE VIRTUAL PROCEDURE \n").append(// $NON-NLS-1$
"BEGIN\n").append(// $NON-NLS-1$
"SELECT param from pm1.g1 union select e1 from pm1.g1 order by param limit 2;\n").append(// $NON-NLS-1$
"END");
addProc(metadata, "sq1", procedure.toString(), new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }, new String[] { "param" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
// $NON-NLS-1$
String userUpdateStr = "EXEC pm1.sq1(1)";
FakeDataManager dataMgr = exampleDataManager(metadata);
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
helpTestProcess(plan, new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "1" }), // $NON-NLS-1$
Arrays.asList(new Object[] { "First" }) }, dataMgr, metadata);
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestProcedureProcessor method testTeiid5001.
@Test
public void testTeiid5001() throws Exception {
ParseInfo.REQUIRE_UNQUALIFIED_NAMES = false;
try {
String sql = "SELECT d.id FROM ( SELECT 'l1' as domain ) dim_md_domains_to_load, table(CALL testcase.proc_web_avg_visit_duration_empty(\"domain\" => domain)) x JOIN testcase.dim_md_date_ranges d ON true";
TransformationMetadata tm = RealMetadataFactory.fromDDL("CREATE VIEW testcase.dim_md_date_ranges AS SELECT 1 as \"id\" union all select 2 " + "CREATE VIRTUAL PROCEDURE proc_web_avg_visit_duration_empty( domain string ) RETURNS (i integer) AS BEGIN select 1; END", "x", "testcase");
ProcessorPlan plan = getProcedurePlan(sql, tm);
HardcodedDataManager dataManager = new HardcodedDataManager(tm);
// $NON-NLS-1$
List[] expected = new List[] { Arrays.asList(1), Arrays.asList(2) };
helpTestProcess(plan, expected, dataManager, tm);
} finally {
ParseInfo.REQUIRE_UNQUALIFIED_NAMES = true;
}
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestProcedureProcessor method testEvaluatableLimit.
@Test
public void testEvaluatableLimit() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.example1();
StringBuffer procedure = // $NON-NLS-1$
new StringBuffer("CREATE VIRTUAL PROCEDURE \n").append(// $NON-NLS-1$
"BEGIN\n").append(// $NON-NLS-1$
"SELECT e1 from pm1.g1 limit param;\n").append(// $NON-NLS-1$
"END");
addProc(metadata, "sq1", procedure.toString(), new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }, new String[] { "param" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
FakeDataManager dataMgr = exampleDataManager(metadata);
// $NON-NLS-1$
String userUpdateStr = "EXEC pm1.sq1(1)";
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
helpTestProcess(plan, new List[] { Arrays.asList(new Object[] { "First" }) }, dataMgr, // $NON-NLS-1$
metadata);
// $NON-NLS-1$
userUpdateStr = "EXEC pm1.sq1(-1)";
plan = getProcedurePlan(userUpdateStr, metadata);
try {
helpTestProcess(plan, new List[] { Arrays.asList(new Object[] { "First" }) }, dataMgr, // $NON-NLS-1$
metadata);
fail();
} catch (QueryValidatorException e) {
// shouldn't allow -1
}
}
use of org.teiid.query.metadata.TransformationMetadata 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);
}
Aggregations