use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestProcedureProcessor method testDDLProcTransactionNonTransactionalJoin.
@Test
public void testDDLProcTransactionNonTransactionalJoin() throws Exception {
String ddl = "create foreign procedure proc () returns table(col string);" + // $NON-NLS-1$
"create virtual procedure virt() as begin select * from proc, proc as x; end";
TransformationMetadata metadata = RealMetadataFactory.fromDDL(ddl, "x", "y");
// $NON-NLS-1$
String userQuery = "EXEC virt()";
ProcessorPlan plan = getProcedurePlan(userQuery, metadata);
assertTrue(plan.requiresTransaction(false));
BasicSourceCapabilities bsc = new BasicSourceCapabilities();
bsc.setSourceProperty(Capability.TRANSACTION_SUPPORT, TransactionSupport.NONE);
plan = getProcedurePlan(userQuery, metadata, new DefaultCapabilitiesFinder(bsc));
assertFalse(plan.requiresTransaction(false));
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestProcedureProcessor method testParameterAssignments.
@Test
public void testParameterAssignments() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.exampleBQTCached();
// $NON-NLS-1$
String userQuery = "EXEC TEIIDSP7(1)";
HardcodedDataManager dataMgr = new HardcodedDataManager();
ProcessorPlan plan = getProcedurePlan(userQuery, metadata);
dataMgr.addData("x = EXEC spTest9(1)", new List[] { Arrays.asList(3) });
dataMgr.addData("EXEC spTest11(3, null)", new List[] { Arrays.asList("1", 1, null), Arrays.asList(null, null, 4) });
List[] expected = new List[] { Arrays.asList("34") };
helpTestProcess(plan, expected, dataMgr, metadata);
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestProcedureProcessor method testUDFCorrelated.
@Test
public void testUDFCorrelated() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.fromDDL("CREATE VIRTUAL FUNCTION f1(x integer) RETURNS string as return (select e1 from g1 where e2 = x/2);; create foreign table g1 (e1 string, e2 integer);", "x", "y");
ProcessorPlan plan = helpGetPlan("select * from g1, table ( select f1 (g1.e2)) t;", metadata);
CommandContext cc = TestProcessor.createCommandContext();
cc.setMetadata(metadata);
HardcodedDataManager hdm = new HardcodedDataManager();
hdm.addData("SELECT y.g1.e1, y.g1.e2 FROM y.g1", Arrays.asList("a", 1), Arrays.asList("b", 2));
hdm.addData("SELECT y.g1.e2, y.g1.e1 FROM y.g1", Arrays.asList(1, "a"), Arrays.asList(2, "b"));
hdm.setBlockOnce(true);
helpProcess(plan, cc, hdm, new List[] { Arrays.asList("a", 1, null), Arrays.asList("b", 2, "a") });
}
use of org.teiid.query.metadata.TransformationMetadata 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.metadata.TransformationMetadata in project teiid by teiid.
the class TestProcedureProcessor method testReturnParamWithNoResultSetVirtual.
@Test
public void testReturnParamWithNoResultSetVirtual() throws Exception {
// $NON-NLS-1$
String sql = "EXEC TEIIDSP8(51)";
TransformationMetadata metadata = RealMetadataFactory.exampleBQTCached();
ProcessorPlan plan = getProcedurePlan(sql, metadata);
// Set up data
FakeDataManager dataMgr = new FakeDataManager();
// Create expected results
// $NON-NLS-1$
List[] expected = new List[] { Arrays.asList(51) };
helpTestProcess(plan, expected, dataMgr, metadata);
}
Aggregations