use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestProcedureProcessor method testDynamicCommandValidationFails.
@Test
public void testDynamicCommandValidationFails() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.example1();
addProc(metadata, "sq2", // $NON-NLS-1$ //$NON-NLS-2$
"CREATE VIRTUAL PROCEDURE BEGIN\n" + "declare object VARIABLES.x; execute string 'SELECT xmlelement(name elem, x)'; select '1', 2; 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);
try {
helpTestProcess(plan, null, dataMgr, metadata);
fail("exception expected");
} catch (QueryProcessingException e) {
}
}
use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestProcedureProcessor method testVirtualProcedure17.
@Test
public void testVirtualProcedure17() throws Exception {
// $NON-NLS-1$
String userUpdateStr = "EXEC pm1.vsp21(7)";
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
// Set up data
FakeDataManager dataMgr = exampleDataManager(metadata);
ProcessorPlan plan = getProcedurePlan(userUpdateStr, 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(15) }), // $NON-NLS-1$
Arrays.asList(new Object[] { "Third", Integer.valueOf(51) }), // $NON-NLS-1$
Arrays.asList(new Object[] { "Fourth", Integer.valueOf(7) }) };
helpTestProcess(plan, expected, dataMgr, metadata);
}
use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestProcedureProcessor method testVirtualProcedure8.
@Test
public void testVirtualProcedure8() throws Exception {
// $NON-NLS-1$
String userUpdateStr = "EXEC pm1.vsp9(51)";
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
FakeDataManager dataMgr = exampleDataManager(metadata);
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
// Create expected results
List[] expected = new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "Third" }) };
helpTestProcess(plan, expected, dataMgr, metadata);
}
use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestProcedureProcessor method testDynamicUpdateInto.
@Test
public void testDynamicUpdateInto() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.example1Cached();
String query = // $NON-NLS-1$ //$NON-NLS-2$
"BEGIN " + " execute immediate 'delete from pm1.g1' as v integer into #temp; select * from #temp with return; end";
FakeDataManager dataMgr = exampleDataManager(metadata);
ProcessorPlan plan = helpGetPlan(query, metadata);
helpProcess(plan, dataMgr, new List[] { Arrays.asList(0) });
}
use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestProcedureProcessor method testLoopsWithLabels.
@Test
public void testLoopsWithLabels() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.example1();
// $NON-NLS-1$
StringBuffer procedure = new StringBuffer("CREATE VIRTUAL PROCEDURE \n");
// $NON-NLS-1$
procedure.append("y: BEGIN\n");
// $NON-NLS-1$
procedure.append("declare integer VARIABLES.e2_total=param1;\n");
// $NON-NLS-1$
procedure.append("x: loop on (select e2 as x from pm1.g1) as mycursor\n");
// $NON-NLS-1$
procedure.append("BEGIN\n");
// $NON-NLS-1$
procedure.append("e2_total=e2_total+mycursor.x;\n");
// $NON-NLS-1$
procedure.append("loop on (select e2 as x from pm1.g1) as mycursor1\n");
// $NON-NLS-1$
procedure.append("BEGIN\n");
// $NON-NLS-1$
procedure.append("if (e2_total < 5)\n");
// $NON-NLS-1$
procedure.append("break x;\n");
// $NON-NLS-1$
procedure.append("else if (e2_total > 50)\n");
// $NON-NLS-1$
procedure.append("leave y;\n");
// $NON-NLS-1$
procedure.append("e2_total=e2_total+mycursor1.x;");
// $NON-NLS-1$
procedure.append("END\n");
// $NON-NLS-1$
procedure.append("END\n");
// $NON-NLS-1$
procedure.append("SELECT VARIABLES.e2_total;\n");
// $NON-NLS-1$
procedure.append("END");
addProc(metadata, "sq2", procedure.toString(), new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER }, new String[] { "param1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
// $NON-NLS-1$
String userUpdateStr = "EXEC pm1.sq2(1)";
FakeDataManager dataMgr = exampleDataManager(metadata);
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
// Create expected results
List[] expected = new List[] {};
helpTestProcess(plan, expected, dataMgr, metadata);
expected = new List[] { Arrays.asList(0) };
// $NON-NLS-1$
userUpdateStr = "EXEC pm1.sq2(-5)";
plan = getProcedurePlan(userUpdateStr, metadata);
helpTestProcess(plan, expected, dataMgr, metadata);
}
Aggregations