use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestProcedureProcessor method testMultipleReturnable.
@Test
public void testMultipleReturnable() 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; 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<?>[] { Arrays.asList("a", 1) };
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 testDyanmicAnonBlockInto.
@Test(expected = QueryProcessingException.class)
public void testDyanmicAnonBlockInto() throws Exception {
// $NON-NLS-1$
String sql = "begin execute immediate 'begin select 2; end' as x integer into #temp; 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);
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestProcedureProcessor method testReturnStatementWithDynamicCommad.
@Test
public void testReturnStatementWithDynamicCommad() throws Exception {
String ddl = "create virtual procedure proc (z STRING) returns integer as begin execute immediate 'select '' || z || '''; return 1; end;";
TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl);
// $NON-NLS-1$
String sql = "{? = call proc('a')}";
ProcessorPlan plan = getProcedurePlan(sql, tm);
HardcodedDataManager dataManager = new HardcodedDataManager(tm);
// $NON-NLS-1$
List[] expected = new List[] { Arrays.asList(1) };
helpTestProcess(plan, expected, dataManager, tm);
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestProcedureProcessor method testVarArgsNull.
@Test
public void testVarArgsNull() throws Exception {
String ddl = "create foreign procedure proc (x integer, VARIADIC z integer not null); create virtual procedure vproc (x integer, VARIADIC z integer) returns integer as begin \"return\" = z[2] + array_length(z); call proc(x, z); end;";
TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl);
// $NON-NLS-1$
String sql = "call vproc(1, cast(null as integer[]))";
ProcessorPlan plan = getProcedurePlan(sql, tm);
HardcodedDataManager dataManager = new HardcodedDataManager(tm);
dataManager.addData("EXEC proc(1)", new List<?>[0]);
// Create expected results
// $NON-NLS-1$
List[] expected = new List[] { Collections.singletonList(null) };
helpTestProcess(plan, expected, dataManager, tm);
// $NON-NLS-1$
sql = "call vproc(x=>1, z=>null)";
plan = getProcedurePlan(sql, tm);
helpTestProcess(plan, expected, dataManager, tm);
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestProcErrors method testExceptionHandlingDynamicError.
@Test
public void testExceptionHandlingDynamicError() throws Exception {
String ddl = "create virtual procedure vproc (x integer) returns integer as begin " + "execute immediate 'select x/0';" + "exception e " + "execute immediate 'select x' as x integer into #temp; " + "\"return\" = (select x from #temp);" + "end;";
TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl);
// $NON-NLS-1$
String sql = "call vproc(1)";
ProcessorPlan plan = getProcedurePlan(sql, tm);
HardcodedDataManager dataManager = new HardcodedDataManager(tm);
helpTestProcess(plan, new List[] { Arrays.asList(1) }, dataManager, tm);
}
Aggregations