Search in sources :

Example 36 with FakeDataManager

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

the class TestProcedureProcessor method testDynamicCommandValidationFails.

@Test
public void testDynamicCommandValidationFails() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.example1();
    addProc(metadata, "sq2", // $NON-NLS-1$ //$NON-NLS-2$
    "CREATE VIRTUAL PROCEDURE BEGIN\n" + "declare object VARIABLES.x; execute string 'SELECT xmlelement(name elem, x)'; select '1', 2; 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')";
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    try {
        helpTestProcess(plan, null, dataMgr, metadata);
        fail("exception expected");
    } catch (QueryProcessingException e) {
    }
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) FakeDataManager(org.teiid.query.processor.FakeDataManager) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) QueryProcessingException(org.teiid.api.exception.query.QueryProcessingException) Test(org.junit.Test)

Example 37 with FakeDataManager

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

the class TestProcedureProcessor method testVirtualProcedure17.

@Test
public void testVirtualProcedure17() throws Exception {
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.vsp21(7)";
    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", Integer.valueOf(5) }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Second", Integer.valueOf(15) }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Third", Integer.valueOf(51) }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Fourth", Integer.valueOf(7) }) };
    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 38 with FakeDataManager

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

the class TestProcedureProcessor method testVirtualProcedure8.

@Test
public void testVirtualProcedure8() throws Exception {
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.vsp9(51)";
    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[] { "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 39 with FakeDataManager

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

the class TestProcedureProcessor method testDynamicUpdateInto.

@Test
public void testDynamicUpdateInto() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.example1Cached();
    String query = // $NON-NLS-1$ //$NON-NLS-2$
    "BEGIN " + " execute immediate 'delete from pm1.g1' as v integer into #temp; select * from #temp with return; end";
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = helpGetPlan(query, metadata);
    helpProcess(plan, dataMgr, new List[] { Arrays.asList(0) });
}
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 40 with FakeDataManager

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

the class TestProcedureProcessor method testLoopsWithLabels.

@Test
public void testLoopsWithLabels() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.example1();
    // $NON-NLS-1$
    StringBuffer procedure = new StringBuffer("CREATE VIRTUAL PROCEDURE \n");
    // $NON-NLS-1$
    procedure.append("y: BEGIN\n");
    // $NON-NLS-1$
    procedure.append("declare integer VARIABLES.e2_total=param1;\n");
    // $NON-NLS-1$
    procedure.append("x: loop on (select e2 as x from pm1.g1) as mycursor\n");
    // $NON-NLS-1$
    procedure.append("BEGIN\n");
    // $NON-NLS-1$
    procedure.append("e2_total=e2_total+mycursor.x;\n");
    // $NON-NLS-1$
    procedure.append("loop on (select e2 as x from pm1.g1) as mycursor1\n");
    // $NON-NLS-1$
    procedure.append("BEGIN\n");
    // $NON-NLS-1$
    procedure.append("if (e2_total < 5)\n");
    // $NON-NLS-1$
    procedure.append("break x;\n");
    // $NON-NLS-1$
    procedure.append("else if (e2_total > 50)\n");
    // $NON-NLS-1$
    procedure.append("leave y;\n");
    // $NON-NLS-1$
    procedure.append("e2_total=e2_total+mycursor1.x;");
    // $NON-NLS-1$
    procedure.append("END\n");
    // $NON-NLS-1$
    procedure.append("END\n");
    // $NON-NLS-1$
    procedure.append("SELECT VARIABLES.e2_total;\n");
    // $NON-NLS-1$
    procedure.append("END");
    addProc(metadata, "sq2", procedure.toString(), new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER }, new String[] { "param1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.sq2(1)";
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    // Create expected results
    List[] expected = new List[] {};
    helpTestProcess(plan, expected, dataMgr, metadata);
    expected = new List[] { Arrays.asList(0) };
    // $NON-NLS-1$
    userUpdateStr = "EXEC pm1.sq2(-5)";
    plan = getProcedurePlan(userUpdateStr, metadata);
    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