use of org.teiid.query.processor.FakeDataManager 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.processor.FakeDataManager 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.processor.FakeDataManager 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.processor.FakeDataManager in project teiid by teiid.
the class TestProcedureProcessor method testDynamicCommandPositional.
@Test
public void testDynamicCommandPositional() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.example1();
addProc(metadata, "sq2", // $NON-NLS-1$ //$NON-NLS-2$
"CREATE VIRTUAL PROCEDURE BEGIN\n" + "execute string 'select e1 as x, e2 from pm1.g1'; END", new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING }, new String[] { "in" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
// $NON-NLS-1$
String userUpdateStr = "EXEC pm1.sq2('test')";
FakeDataManager dataMgr = exampleDataManager(metadata);
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
helpTestProcess(plan, new List[] { // $NON-NLS-1$ //$NON-NLS-2$
Arrays.asList("First", "5"), // $NON-NLS-1$ //$NON-NLS-2$
Arrays.asList("Second", "15"), Arrays.asList("Third", "51") }, dataMgr, // $NON-NLS-1$ //$NON-NLS-2$
metadata);
}
use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestProcedureProcessor method exampleDataManager2.
private FakeDataManager exampleDataManager2(QueryMetadataInterface metadata) throws TeiidException {
FakeDataManager dataMgr = new FakeDataManager();
dataMgr.registerTuples(metadata, "pm1.g1", new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "First", Integer.valueOf(5), new Boolean(true), new Double(1.003) }), // $NON-NLS-1$
Arrays.asList(new Object[] { "Second", Integer.valueOf(15), new Boolean(true), new Double(2.003) }), // $NON-NLS-1$
Arrays.asList(new Object[] { "Third", Integer.valueOf(51), new Boolean(true), new Double(3.003) }) });
dataMgr.registerTuples(metadata, "pm1.g2", new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "First", Integer.valueOf(5), new Boolean(true), new Double(1.003) }), // $NON-NLS-1$
Arrays.asList(new Object[] { "Second", Integer.valueOf(15), new Boolean(true), new Double(2.003) }), // $NON-NLS-1$
Arrays.asList(new Object[] { "Third", Integer.valueOf(51), new Boolean(true), new Double(3.003) }) });
dataMgr.registerTuples(metadata, "pm2.g1", new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "First", Integer.valueOf(5), new Boolean(true), new Double(1.003) }), // $NON-NLS-1$
Arrays.asList(new Object[] { "Second", Integer.valueOf(15), new Boolean(true), new Double(2.003) }), // $NON-NLS-1$
Arrays.asList(new Object[] { "Third", Integer.valueOf(51), new Boolean(true), new Double(3.003) }) });
dataMgr.registerTuples(metadata, "pm2.g2", new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "First", Integer.valueOf(5), new Boolean(true), new Double(1.003) }), // $NON-NLS-1$
Arrays.asList(new Object[] { "Second", Integer.valueOf(15), new Boolean(true), new Double(2.003) }), // $NON-NLS-1$
Arrays.asList(new Object[] { "Third", Integer.valueOf(51), new Boolean(true), new Double(3.003) }) });
return dataMgr;
}
Aggregations