Search in sources :

Example 41 with FakeDataManager

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

the class TestProcedureProcessor method testVirtualProcedure31.

@Test
public void testVirtualProcedure31() throws Exception {
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.vsp31(51)";
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    // Set up data
    FakeDataManager dataMgr = exampleDataManager(metadata);
    // Create expected results
    List[] expected = new List[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { "Third" }) };
    helpTestProcess(plan, expected, dataMgr, metadata);
}
Also used : FakeDataManager(org.teiid.query.processor.FakeDataManager) 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 42 with FakeDataManager

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

the class TestProcedureProcessor method testDynamicCommandIncorrectProjectSymbolDatatypes.

@Test
public void testDynamicCommandIncorrectProjectSymbolDatatypes() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.example1();
    addProc(metadata, "sq2", // $NON-NLS-1$ //$NON-NLS-2$
    "CREATE VIRTUAL PROCEDURE BEGIN\n" + "execute string 'select e1 from pm1.g1'; END", new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER }, new String[0], // $NON-NLS-1$
    new String[0]);
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.sq2()";
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    // $NON-NLS-1$
    helpTestProcessFailure(plan, dataMgr, "TEIID30168 Couldn't execute the dynamic SQL command \"EXECUTE IMMEDIATE 'select e1 from pm1.g1'\" with the SQL statement \"select e1 from pm1.g1\" due to: The datatype 'string' for element 'e1' in the dynamic SQL cannot be implicitly converted to 'integer'.", 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 43 with FakeDataManager

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

the class TestProcedureProcessor method testVirtualProcedure16.

@Test
public void testVirtualProcedure16() throws Exception {
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.vsp20()";
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    // Set up data
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    // Create expected results
    List[] expected = new List[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { "First" }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Second" }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Third" }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Fourth" }) };
    // $NON-NLS-1$
    CommandContext context = new CommandContext("pID", null, null, null, 1);
    context.setMetadata(metadata);
    // ensure that the final temp result set will not be deleted prematurely
    context.setProcessorBatchSize(1);
    TestProcessor.helpProcess(plan, context, dataMgr, expected);
}
Also used : CommandContext(org.teiid.query.util.CommandContext) FakeDataManager(org.teiid.query.processor.FakeDataManager) 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 44 with FakeDataManager

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

the class TestProcedureProcessor method testVirtualProcedure5.

@Test
public void testVirtualProcedure5() throws Exception {
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.vsp6()";
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    // Create expected results
    List[] expected = new List[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { "Second" }) };
    helpTestProcess(plan, expected, dataMgr, metadata);
}
Also used : FakeDataManager(org.teiid.query.processor.FakeDataManager) 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 45 with FakeDataManager

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

the class TestProcedureProcessor method testAssignmentWithCase.

@Test
public void testAssignmentWithCase() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.example1();
    String sql = // $NON-NLS-1$
    new StringBuffer("declare integer caseValue = ").append(// $NON-NLS-1$
    "CASE").append(// $NON-NLS-1$
    " WHEN pm1.sq1.param='a' THEN 0").append(// $NON-NLS-1$
    " WHEN pm1.sq1.param='b' THEN 1").append(// $NON-NLS-1$
    " WHEN pm1.sq1.param='c' THEN 2").append(// $NON-NLS-1$
    " WHEN pm1.sq1.param='d' THEN 3").append(// $NON-NLS-1$
    " ELSE 9999").append(" END").toString();
    addProc(metadata, "sq1", // $NON-NLS-1$ //$NON-NLS-2$
    "CREATE VIRTUAL PROCEDURE BEGIN\n" + sql + "; SELECT caseValue; END", new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER }, new String[] { "param" }, // $NON-NLS-1$
    new String[] { DataTypeManager.DefaultDataTypes.STRING });
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.sq1('d')";
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    // Create expected results
    List[] expected = new List[] { Arrays.asList(new Object[] { Integer.valueOf(3) }) };
    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

FakeDataManager (org.teiid.query.processor.FakeDataManager)112 Test (org.junit.Test)103 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)86 ArrayList (java.util.ArrayList)81 List (java.util.List)81 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)48 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)35 CommandContext (org.teiid.query.util.CommandContext)8 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)7 FunctionDescriptor (org.teiid.query.function.FunctionDescriptor)6 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 BufferManager (org.teiid.common.buffer.BufferManager)4 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)3 Constant (org.teiid.query.sql.symbol.Constant)3 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)3 Function (org.teiid.query.sql.symbol.Function)3 Evaluator (org.teiid.query.eval.Evaluator)2 TempMetadataStore (org.teiid.query.metadata.TempMetadataStore)2