use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestProcedureProcessor method testVirtualProcedure4.
@Test
public void testVirtualProcedure4() throws Exception {
// $NON-NLS-1$
String userUpdateStr = "EXEC pm1.vsp5()";
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[] { "First" }) };
helpTestProcess(plan, expected, dataMgr, metadata);
}
use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestProcedureProcessor method testVirtualProcedureWithCreate.
@Test
public void testVirtualProcedureWithCreate() throws Exception {
// $NON-NLS-1$
String userUpdateStr = "EXEC pm1.vsp60()";
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[] { "First" }), // $NON-NLS-1$
Arrays.asList(new Object[] { "Second" }), // $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 testOuterTempTableExecuteImmediateTarget.
@Test
public void testOuterTempTableExecuteImmediateTarget() 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" + " loop on (select 1 as a union all select 2) as c \n" + " begin \n" + " execute immediate 'select c.a' as e1 string into t1; \n" + " end \n" + // $NON-NLS-1$
" select * 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("1"), Arrays.asList("2") };
helpTestProcess(plan, expected, dataMgr, metadata);
}
use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestProcedureProcessor method testDoubleDrop.
/**
* We allow drops to silently fail
*/
@Test
public void testDoubleDrop() 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 t1 (e1 string);\n");
// $NON-NLS-1$
procedure.append("select e1 into t1 from pm1.g1;\n");
// $NON-NLS-1$
procedure.append("drop table t1;\n");
// $NON-NLS-1$
procedure.append("drop table t1;\n");
// $NON-NLS-1$
procedure.append("SELECT '1';\n");
// $NON-NLS-1$
procedure.append("END");
addProc(metadata, procedure.toString());
// $NON-NLS-1$
String userUpdateStr = "EXEC pm1.sq2()";
FakeDataManager dataMgr = exampleDataManager(metadata);
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
helpTestProcess(plan, new List[] { Arrays.asList("1") }, dataMgr, metadata);
}
use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestProcedureProcessor method testNonDeterministicEvaluation.
/**
* Tests non-deterministic evaluation of the rand function. There are two important things happening
* 1. is that the evaluation of the rand function is delayed until processing time (which actually has predictable
* values since the test initializes the command context with the same seed)
* 2. The values are different, meaning that we got individual evaluations
*
* If this function were deterministic, it would be evaluated during rewrite to a single value.
*/
@Test
public void testNonDeterministicEvaluation() throws Exception {
StringBuffer procedure = // $NON-NLS-1$
new StringBuffer("CREATE VIRTUAL PROCEDURE \n").append(// $NON-NLS-1$
"BEGIN\n").append(// $NON-NLS-1$
"DECLARE integer x = 0;\n").append(// $NON-NLS-1$
"CREATE LOCAL TEMPORARY TABLE #TEMP (e1 integer);\n").append(// $NON-NLS-1$
"while (x < 2)\n").append(// $NON-NLS-1$
"BEGIN\n").append(// $NON-NLS-1$
"insert into #temp (e1) values (convert(rand() * 1000, integer));\n").append(// $NON-NLS-1$
"x = x + 1;\n").append(// $NON-NLS-1$
"END\n").append(// $NON-NLS-1$
"SELECT cast(e1 as string) FROM #TEMP;\n").append(// $NON-NLS-1$
"END");
QueryMetadataInterface metadata = createProcedureMetadata(procedure.toString());
// $NON-NLS-1$
String userUpdateStr = "EXEC pm1.sq1()";
FakeDataManager dataMgr = exampleDataManager(metadata);
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
helpTestProcess(plan, new List[] { Arrays.asList("240"), Arrays.asList("637") }, dataMgr, metadata);
}
Aggregations