Search in sources :

Example 16 with FakeDataManager

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

the class TestProcedureProcessor method testVirtualProcedure4.

@Test
public void testVirtualProcedure4() throws Exception {
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.vsp5()";
    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[] { "First" }) };
    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 17 with FakeDataManager

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

the class TestProcedureProcessor method testVirtualProcedureWithCreate.

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

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

the class TestProcedureProcessor method testOuterTempTableExecuteImmediateTarget.

@Test
public void testOuterTempTableExecuteImmediateTarget() 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" + " loop on (select 1 as a union all select 2) as c \n" + " begin \n" + " execute immediate 'select c.a' as e1 string into t1; \n" + " end \n" + // $NON-NLS-1$
    " select * 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("1"), Arrays.asList("2") };
    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 19 with FakeDataManager

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

the class TestProcedureProcessor method testDoubleDrop.

/**
 *  We allow drops to silently fail
 */
@Test
public void testDoubleDrop() 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 t1 (e1 string);\n");
    // $NON-NLS-1$
    procedure.append("select e1 into t1 from pm1.g1;\n");
    // $NON-NLS-1$
    procedure.append("drop table t1;\n");
    // $NON-NLS-1$
    procedure.append("drop table t1;\n");
    // $NON-NLS-1$
    procedure.append("SELECT '1';\n");
    // $NON-NLS-1$
    procedure.append("END");
    addProc(metadata, procedure.toString());
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.sq2()";
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    helpTestProcess(plan, new List[] { Arrays.asList("1") }, dataMgr, 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 20 with FakeDataManager

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

the class TestProcedureProcessor method testNonDeterministicEvaluation.

/**
 * Tests non-deterministic evaluation of the rand function.  There are two important things happening
 * 1. is that the evaluation of the rand function is delayed until processing time (which actually has predictable
 * values since the test initializes the command context with the same seed)
 * 2. The values are different, meaning that we got individual evaluations
 *
 * If this function were deterministic, it would be evaluated during rewrite to a single value.
 */
@Test
public void testNonDeterministicEvaluation() throws Exception {
    StringBuffer procedure = // $NON-NLS-1$
    new StringBuffer("CREATE VIRTUAL PROCEDURE \n").append(// $NON-NLS-1$
    "BEGIN\n").append(// $NON-NLS-1$
    "DECLARE integer x = 0;\n").append(// $NON-NLS-1$
    "CREATE LOCAL TEMPORARY TABLE #TEMP (e1 integer);\n").append(// $NON-NLS-1$
    "while (x < 2)\n").append(// $NON-NLS-1$
    "BEGIN\n").append(// $NON-NLS-1$
    "insert into #temp (e1) values (convert(rand() * 1000, integer));\n").append(// $NON-NLS-1$
    "x = x + 1;\n").append(// $NON-NLS-1$
    "END\n").append(// $NON-NLS-1$
    "SELECT cast(e1 as string) FROM #TEMP;\n").append(// $NON-NLS-1$
    "END");
    QueryMetadataInterface metadata = createProcedureMetadata(procedure.toString());
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.sq1()";
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    helpTestProcess(plan, new List[] { Arrays.asList("240"), Arrays.asList("637") }, dataMgr, metadata);
}
Also used : FakeDataManager(org.teiid.query.processor.FakeDataManager) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) 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