use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestProcedureProcessor method testDynamicCommandWithIntoExpressionInNestedBlock.
@Test
public void testDynamicCommandWithIntoExpressionInNestedBlock() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.example1Cached();
String query = "BEGIN\n" + "EXECUTE IMMEDIATE 'SELECT e1 FROM pm1.g1 WHERE e1 = ''First''' as x string into #temp;\n" + "declare string VARIABLES.RESULT = select x from #temp;\n" + "IF (VARIABLES.RESULT = 'First')\n" + " BEGIN ATOMIC\n" + " EXECUTE IMMEDIATE 'SELECT e1 FROM pm1.g1' AS x string;" + " EXECUTE IMMEDIATE 'SELECT e1 FROM pm1.g1 WHERE e1 = ''Second''' as x string into #temp2 WITHOUT RETURN;\n" + " VARIABLES.RESULT = select x from #temp2;\n" + " END" + " select VARIABLES.RESULT;" + "END";
FakeDataManager dataMgr = exampleDataManager(metadata);
ProcessorPlan plan = getProcedurePlan(query, metadata);
// Create expected results
List[] expected = new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "Second" }) };
helpTestProcess(plan, expected, dataMgr, metadata);
}
use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestProcedureProcessor method testUpdateDeleteTemp.
@Test
public void testUpdateDeleteTemp() throws Exception {
String proc = // $NON-NLS-1$
"CREATE VIRTUAL PROCEDURE " + // $NON-NLS-1$
"BEGIN " + // $NON-NLS-1$
" select e1, e2, e3, e4 into #t1 from pm1.g1;\n" + // $NON-NLS-1$
" update #t1 set e1 = 1 where e4 < 2;\n" + // $NON-NLS-1$
" delete from #t1 where e4 > 2;\n" + // $NON-NLS-1$
" select e1 from #t1;\n" + // $NON-NLS-1$
"END";
QueryMetadataInterface metadata = createProcedureMetadata(proc);
// $NON-NLS-1$
String userQuery = "SELECT * FROM (EXEC pm1.sq1()) as proc";
FakeDataManager dataMgr = exampleDataManager2(metadata);
ProcessorPlan plan = getProcedurePlan(userQuery, metadata, TestOptimizer.getGenericFinder());
List[] expected = new List[] { Arrays.asList(new Object[] { String.valueOf(1) }) };
helpTestProcess(plan, expected, dataMgr, metadata);
}
use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestProcedureProcessor method testDefect19982.
@Test
public void testDefect19982() throws Exception {
// $NON-NLS-1$
String userUpdateStr = "EXEC pm1.vsp55(5)";
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
// Set up data
FakeDataManager dataMgr = exampleDataManager(metadata);
// Create expected results
List[] expected = new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "First", Integer.valueOf(5) }), // $NON-NLS-1$
Arrays.asList(new Object[] { "Second", Integer.valueOf(5) }), // $NON-NLS-1$
Arrays.asList(new Object[] { "Third", Integer.valueOf(5) }) };
helpTestProcess(plan, expected, dataMgr, metadata);
}
use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestProcedureProcessor method testTempSubqueryInput.
@Test
public void testTempSubqueryInput() throws Exception {
String proc = // $NON-NLS-1$
"CREATE VIRTUAL PROCEDURE " + // $NON-NLS-1$
"BEGIN " + // $NON-NLS-1$
" create local temporary table t1 (e1 string);\n" + // $NON-NLS-1$
" select e1 into t1 from pm1.g1;\n" + // $NON-NLS-1$
" select cast(e2 as string) from (exec pm1.sq2((select max(e1) from t1))) x;\n" + // $NON-NLS-1$
"END";
QueryMetadataInterface metadata = createProcedureMetadata(proc);
// $NON-NLS-1$
String userQuery = "SELECT * FROM (EXEC pm1.sq1()) as proc";
FakeDataManager dataMgr = exampleDataManager2(metadata);
ProcessorPlan plan = getProcedurePlan(userQuery, metadata, TestOptimizer.getGenericFinder());
List[] expected = new List[] { Arrays.asList("51") };
helpTestProcess(plan, expected, dataMgr, metadata);
}
use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestProcedureProcessor method testNonQueryPushdownValidation.
@Test
public void testNonQueryPushdownValidation() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.example1();
// $NON-NLS-1$
StringBuffer procedure = new StringBuffer("CREATE VIRTUAL PROCEDURE \n");
// $NON-NLS-1$
procedure.append("BEGIN\n");
// $NON-NLS-1$
procedure.append("create local temporary table x (y string);\n");
// $NON-NLS-1$
procedure.append("declare string s = 'foo';\n");
// $NON-NLS-1$
procedure.append("update x set y = in1 || s;\n");
// $NON-NLS-1$
procedure.append("update pm1.g1 set e1 = lookup('pm1.g1', 'e1', 'e2', in1);\n");
// $NON-NLS-1$
procedure.append("exec pm1.sq2(in1 || 'foo');\n");
// $NON-NLS-1$
procedure.append("END");
addProc(metadata, "sq1", procedure.toString(), new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER }, new String[] { "in1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
// $NON-NLS-1$
String userUpdateStr = "EXEC pm1.sq1(1)";
FakeDataManager dataMgr = exampleDataManager(metadata);
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
// Create expected results
List[] expected = new List[0];
helpTestProcess(plan, expected, dataMgr, metadata);
}
Aggregations