Search in sources :

Example 61 with HardcodedDataManager

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

the class TestProcedureProcessor method testMultipleReturnable.

@Test
public void testMultipleReturnable() 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; 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<?>[] { Arrays.asList("a", 1) };
    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 62 with HardcodedDataManager

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

the class TestProcedureProcessor method testDyanmicAnonBlockInto.

@Test(expected = QueryProcessingException.class)
public void testDyanmicAnonBlockInto() throws Exception {
    // $NON-NLS-1$
    String sql = "begin execute immediate 'begin select 2; end' as x integer into #temp; 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);
}
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 63 with HardcodedDataManager

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

the class TestProcedureProcessor method testReturnStatementWithDynamicCommad.

@Test
public void testReturnStatementWithDynamicCommad() throws Exception {
    String ddl = "create virtual procedure proc (z STRING) returns integer as begin execute immediate 'select '' || z || '''; return 1; end;";
    TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl);
    // $NON-NLS-1$
    String sql = "{? = call proc('a')}";
    ProcessorPlan plan = getProcedurePlan(sql, tm);
    HardcodedDataManager dataManager = new HardcodedDataManager(tm);
    // $NON-NLS-1$
    List[] expected = new List[] { Arrays.asList(1) };
    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 64 with HardcodedDataManager

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

the class TestProcedureProcessor method testVarArgsNull.

@Test
public void testVarArgsNull() throws Exception {
    String ddl = "create foreign procedure proc (x integer, VARIADIC z integer not null); 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, cast(null as integer[]))";
    ProcessorPlan plan = getProcedurePlan(sql, tm);
    HardcodedDataManager dataManager = new HardcodedDataManager(tm);
    dataManager.addData("EXEC proc(1)", new List<?>[0]);
    // Create expected results
    // $NON-NLS-1$
    List[] expected = new List[] { Collections.singletonList(null) };
    helpTestProcess(plan, expected, dataManager, tm);
    // $NON-NLS-1$
    sql = "call vproc(x=>1, z=>null)";
    plan = getProcedurePlan(sql, tm);
    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 65 with HardcodedDataManager

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

the class TestProcErrors method testExceptionHandlingDynamicError.

@Test
public void testExceptionHandlingDynamicError() throws Exception {
    String ddl = "create virtual procedure vproc (x integer) returns integer as begin " + "execute immediate 'select x/0';" + "exception e " + "execute immediate 'select x' as x integer into #temp; " + "\"return\" = (select x from #temp);" + "end;";
    TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl);
    // $NON-NLS-1$
    String sql = "call vproc(1)";
    ProcessorPlan plan = getProcedurePlan(sql, tm);
    HardcodedDataManager dataManager = new HardcodedDataManager(tm);
    helpTestProcess(plan, new List[] { Arrays.asList(1) }, dataManager, tm);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) 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