Search in sources :

Example 51 with HardcodedDataManager

use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.

the class TestProcedureProcessor method testVarArgs.

@Test
public void testVarArgs() throws Exception {
    String ddl = "create foreign procedure proc (x integer, VARIADIC z integer); 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, 2, 3)";
    ProcessorPlan plan = getProcedurePlan(sql, tm);
    HardcodedDataManager dataManager = new HardcodedDataManager(tm);
    dataManager.addData("EXEC proc(1, 2, 3)", new List<?>[0]);
    // Create expected results
    // $NON-NLS-1$
    List[] expected = new List[] { Arrays.asList(5) };
    helpTestProcess(plan, expected, dataManager, tm);
}
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 52 with HardcodedDataManager

use of org.teiid.query.processor.HardcodedDataManager 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 53 with HardcodedDataManager

use of org.teiid.query.processor.HardcodedDataManager 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 54 with HardcodedDataManager

use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.

the class TestProcedureProcessor method testVirtualProcedure16602.

@Test
public void testVirtualProcedure16602() throws Exception {
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.vsp37()";
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    // Set up data
    HardcodedDataManager dataMgr = new HardcodedDataManager();
    dataMgr.addData("INSERT INTO pm1.g1 (e2) VALUES (5)", new List[] { Arrays.asList(1) });
    // Create expected results
    List[] expected = new List[] { Arrays.asList("1") };
    helpTestProcess(plan, expected, dataMgr, metadata);
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) List(java.util.List) ArrayList(java.util.ArrayList) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 55 with HardcodedDataManager

use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.

the class TestProcedureProcessor method testTeiid5001.

@Test
public void testTeiid5001() throws Exception {
    ParseInfo.REQUIRE_UNQUALIFIED_NAMES = false;
    try {
        String sql = "SELECT d.id FROM ( SELECT 'l1' as domain ) dim_md_domains_to_load, table(CALL testcase.proc_web_avg_visit_duration_empty(\"domain\" => domain)) x JOIN testcase.dim_md_date_ranges d ON true";
        TransformationMetadata tm = RealMetadataFactory.fromDDL("CREATE VIEW testcase.dim_md_date_ranges AS SELECT 1 as \"id\" union all select 2 " + "CREATE VIRTUAL PROCEDURE proc_web_avg_visit_duration_empty( domain string ) RETURNS (i integer) AS BEGIN select 1; END", "x", "testcase");
        ProcessorPlan plan = getProcedurePlan(sql, tm);
        HardcodedDataManager dataManager = new HardcodedDataManager(tm);
        // $NON-NLS-1$
        List[] expected = new List[] { Arrays.asList(1), Arrays.asList(2) };
        helpTestProcess(plan, expected, dataManager, tm);
    } finally {
        ParseInfo.REQUIRE_UNQUALIFIED_NAMES = true;
    }
}
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)

Aggregations

HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)140 Test (org.junit.Test)134 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)97 List (java.util.List)75 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)63 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)53 ArrayList (java.util.ArrayList)44 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)42 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)29 CommandContext (org.teiid.query.util.CommandContext)19 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)14 Options (org.teiid.query.util.Options)6 BufferManagerImpl (org.teiid.common.buffer.impl.BufferManagerImpl)5 RegisterRequestParameter (org.teiid.query.processor.RegisterRequestParameter)4 Command (org.teiid.query.sql.lang.Command)4 TupleSource (org.teiid.common.buffer.TupleSource)3 Insert (org.teiid.query.sql.lang.Insert)3 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)2 TeiidProcessingException (org.teiid.core.TeiidProcessingException)2 TeiidSQLException (org.teiid.jdbc.TeiidSQLException)2