Search in sources :

Example 91 with TransformationMetadata

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));
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 92 with TransformationMetadata

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);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) List(java.util.List) ArrayList(java.util.ArrayList) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 93 with TransformationMetadata

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") });
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) CommandContext(org.teiid.query.util.CommandContext) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 94 with TransformationMetadata

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);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) FakeDataManager(org.teiid.query.processor.FakeDataManager) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 95 with TransformationMetadata

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);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) FakeDataManager(org.teiid.query.processor.FakeDataManager) List(java.util.List) ArrayList(java.util.ArrayList) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Aggregations

TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)427 Test (org.junit.Test)352 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)163 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)108 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)97 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)89 List (java.util.List)83 CommandContext (org.teiid.query.util.CommandContext)64 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)63 ArrayList (java.util.ArrayList)56 TranslationUtility (org.teiid.cdk.api.TranslationUtility)35 MetadataFactory (org.teiid.metadata.MetadataFactory)35 FakeDataManager (org.teiid.query.processor.FakeDataManager)35 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)35 Schema (org.teiid.metadata.Schema)33 Table (org.teiid.metadata.Table)27 FunctionTree (org.teiid.query.function.FunctionTree)22 Column (org.teiid.metadata.Column)21 Command (org.teiid.language.Command)20 UDFSource (org.teiid.query.function.UDFSource)20