Search in sources :

Example 56 with HardcodedDataManager

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

the class TestProcedureProcessor method testDepJoinFullProcessing.

@Test
public void testDepJoinFullProcessing() throws Exception {
    String sql = " BEGIN" + "\n    create local temporary table ssid_version (sysplex varchar, lpar varchar, ssid varchar, version varchar);" + "\n  insert into ssid_version(sysplex, lpar, ssid, version) values ('plex1', 'ca11', 'd91a', 'v5');" + "\n    insert into ssid_version(sysplex, lpar, ssid, version) values ('plex1', 'ca11', 'd91b', 'v6');" + "\n create local temporary table table_spaces_v5 (sysplex varchar, lpar varchar, ssid varchar, table_space_id varchar);" + "\n    insert into table_spaces_v5 (sysplex, lpar, ssid, table_space_id) values ('plex1', 'ca11', 'd91a', 'ts1');" + "\n create local temporary table table_spaces_v6 (sysplex varchar, lpar varchar, ssid varchar, table_space_id varchar);" + "\n    insert into table_spaces_v6 (sysplex, lpar, ssid, table_space_id) values ('plex1', 'ca11', 'd91b', 'ts2');" + "\n select table_space_id from ( select * from (select v.sysplex, v.lpar, v.ssid, t.table_space_id from ssid_version v join table_spaces_v5 t on t.sysplex=v.sysplex and t.lpar=v.lpar and t.ssid=v.ssid option makedep table_spaces_v5) t" + " union all select * from (select v.sysplex, v.lpar, v.ssid, t.table_space_id from ssid_version v join table_spaces_v6 t on t.sysplex=v.sysplex and t.lpar=v.lpar and t.ssid=v.ssid option makedep table_spaces_v6) t" + " ) t where ssid='d91a';" + // + " raise e.exception;"
    "\n   END";
    TransformationMetadata tm = RealMetadataFactory.example1Cached();
    ProcessorPlan plan = getProcedurePlan(sql, tm);
    HardcodedDataManager dataManager = new HardcodedDataManager(tm);
    dataManager.addData("SELECT g1.e1 FROM g1", new List<?>[] { Arrays.asList("a") });
    // $NON-NLS-1$
    List[] expected = new List[] { Arrays.asList("ts1") };
    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 57 with HardcodedDataManager

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

the class TestProcedureProcessor method testReturnable1.

/**
 * Should return the first results
 */
@Test
public void testReturnable1() 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 without return; 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<?>[0];
    helpTestProcess(plan, expected, dataMgr, metadata);
    assertEquals(6, dataMgr.getCommandHistory().size());
}
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 58 with HardcodedDataManager

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

the class TestProcedureProcessor method testDynamicInsert1.

@Test(expected = TeiidProcessingException.class)
public void testDynamicInsert1() throws Exception {
    // $NON-NLS-1$
    String sql = "exec p1(1)";
    TransformationMetadata tm = RealMetadataFactory.fromDDL("create virtual procedure p1(a long) returns (res long) as " + "begin create local temporary table t (x string); execute immediate 'insert into t select ''a''' as res long;  end;", "x", "y");
    ProcessorPlan plan = getProcedurePlan(sql, tm);
    HardcodedDataManager dataManager = new HardcodedDataManager(tm);
    // $NON-NLS-1$
    List[] expected = new List[] {};
    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 59 with HardcodedDataManager

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

the class TestProcedureProcessor method testDyanmicAnonBlockWithReturn.

@Test
public void testDyanmicAnonBlockWithReturn() throws Exception {
    // $NON-NLS-1$
    String sql = "begin execute immediate 'begin select 1; select 1, 2; end'; 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);
    // $NON-NLS-1$
    sql = "begin execute immediate 'begin select 1; select 1, 2; end' as y string; end";
    tm = RealMetadataFactory.example1Cached();
    plan = getProcedurePlan(sql, tm);
    try {
        helpTestProcess(plan, expected, dataManager, tm);
        fail();
    } catch (QueryProcessingException e) {
    }
}
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) QueryProcessingException(org.teiid.api.exception.query.QueryProcessingException) Test(org.junit.Test)

Example 60 with HardcodedDataManager

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

the class TestProcedureProcessor method testOmitDefault.

@Test
public void testOmitDefault() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.fromDDL("CREATE foreign procedure f1(x string not null options (\"teiid_rel:default_handling\" 'omit')) RETURNS string;", "x", "y");
    ProcessorPlan plan = helpGetPlan("exec f1()", metadata);
    CommandContext cc = TestProcessor.createCommandContext();
    cc.setMetadata(metadata);
    HardcodedDataManager hdm = new HardcodedDataManager(metadata);
    hdm.addData("EXEC f1()", Arrays.asList("a"));
    helpProcess(plan, cc, hdm, new List[] { Arrays.asList("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)

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