Search in sources :

Example 96 with FakeDataManager

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

the class TestProcedureProcessor method testDynamicCommandWithIntoExpressionInNestedBlock.

@Test
public void testDynamicCommandWithIntoExpressionInNestedBlock() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.example1Cached();
    String query = "BEGIN\n" + "EXECUTE IMMEDIATE 'SELECT e1 FROM pm1.g1 WHERE e1 = ''First''' as x string into #temp;\n" + "declare string VARIABLES.RESULT = select x from #temp;\n" + "IF (VARIABLES.RESULT = 'First')\n" + "  BEGIN ATOMIC\n" + "  EXECUTE IMMEDIATE 'SELECT e1 FROM pm1.g1' AS x string;" + "  EXECUTE IMMEDIATE 'SELECT e1 FROM pm1.g1 WHERE e1 = ''Second''' as x string into #temp2 WITHOUT RETURN;\n" + "  VARIABLES.RESULT = select x from #temp2;\n" + "  END" + " select VARIABLES.RESULT;" + "END";
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = getProcedurePlan(query, metadata);
    // Create expected results
    List[] expected = new List[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { "Second" }) };
    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)

Example 97 with FakeDataManager

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

the class TestProcedureProcessor method testUpdateDeleteTemp.

@Test
public void testUpdateDeleteTemp() throws Exception {
    String proc = // $NON-NLS-1$
    "CREATE VIRTUAL PROCEDURE " + // $NON-NLS-1$
    "BEGIN " + // $NON-NLS-1$
    " select e1, e2, e3, e4 into #t1 from pm1.g1;\n" + // $NON-NLS-1$
    " update #t1 set e1 = 1 where e4 < 2;\n" + // $NON-NLS-1$
    " delete from #t1 where e4 > 2;\n" + // $NON-NLS-1$
    " select e1 from #t1;\n" + // $NON-NLS-1$
    "END";
    QueryMetadataInterface metadata = createProcedureMetadata(proc);
    // $NON-NLS-1$
    String userQuery = "SELECT * FROM (EXEC pm1.sq1()) as proc";
    FakeDataManager dataMgr = exampleDataManager2(metadata);
    ProcessorPlan plan = getProcedurePlan(userQuery, metadata, TestOptimizer.getGenericFinder());
    List[] expected = new List[] { Arrays.asList(new Object[] { String.valueOf(1) }) };
    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 98 with FakeDataManager

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

the class TestProcedureProcessor method testDefect19982.

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

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

the class TestProcedureProcessor method testTempSubqueryInput.

@Test
public void testTempSubqueryInput() throws Exception {
    String proc = // $NON-NLS-1$
    "CREATE VIRTUAL PROCEDURE " + // $NON-NLS-1$
    "BEGIN " + // $NON-NLS-1$
    " create local temporary table t1 (e1 string);\n" + // $NON-NLS-1$
    " select e1 into t1 from pm1.g1;\n" + // $NON-NLS-1$
    " select cast(e2 as string) from (exec pm1.sq2((select max(e1) from t1))) x;\n" + // $NON-NLS-1$
    "END";
    QueryMetadataInterface metadata = createProcedureMetadata(proc);
    // $NON-NLS-1$
    String userQuery = "SELECT * FROM (EXEC pm1.sq1()) as proc";
    FakeDataManager dataMgr = exampleDataManager2(metadata);
    ProcessorPlan plan = getProcedurePlan(userQuery, metadata, TestOptimizer.getGenericFinder());
    List[] expected = new List[] { Arrays.asList("51") };
    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 100 with FakeDataManager

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

the class TestProcedureProcessor method testNonQueryPushdownValidation.

@Test
public void testNonQueryPushdownValidation() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.example1();
    // $NON-NLS-1$
    StringBuffer procedure = new StringBuffer("CREATE VIRTUAL PROCEDURE \n");
    // $NON-NLS-1$
    procedure.append("BEGIN\n");
    // $NON-NLS-1$
    procedure.append("create local temporary table x (y string);\n");
    // $NON-NLS-1$
    procedure.append("declare string s = 'foo';\n");
    // $NON-NLS-1$
    procedure.append("update x set y = in1 || s;\n");
    // $NON-NLS-1$
    procedure.append("update pm1.g1 set e1 = lookup('pm1.g1', 'e1', 'e2', in1);\n");
    // $NON-NLS-1$
    procedure.append("exec pm1.sq2(in1 || 'foo');\n");
    // $NON-NLS-1$
    procedure.append("END");
    addProc(metadata, "sq1", procedure.toString(), new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER }, new String[] { "in1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.sq1(1)";
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    // Create expected results
    List[] expected = new List[0];
    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