Search in sources :

Example 26 with FakeDataManager

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

the class TestProcedureProcessor method testDynamicCommandRecursion.

@Test
public void testDynamicCommandRecursion() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.example1();
    addProc(metadata, "sq2", // $NON-NLS-1$ //$NON-NLS-2$
    "CREATE VIRTUAL PROCEDURE BEGIN\n" + "execute string 'EXEC pm1.sq2(''First'')' as e1 string, e2 integer; 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);
    helpTestProcessFailure(plan, dataMgr, "TEIID30168 Couldn't execute the dynamic SQL command \"EXECUTE IMMEDIATE 'EXEC pm1.sq2(''First'')' AS e1 string, e2 integer\" with the SQL statement \"EXEC pm1.sq2('First')\" due to: TEIID30347 There is a recursive invocation of group 'pm1.sq2'. Please correct the SQL.", // $NON-NLS-1$
    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 27 with FakeDataManager

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

the class TestProcedureProcessor method testEvaluatableSelectWithOrderBy1.

@Test
public void testEvaluatableSelectWithOrderBy1() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.example1();
    StringBuffer procedure = // $NON-NLS-1$
    new StringBuffer("CREATE VIRTUAL PROCEDURE \n").append(// $NON-NLS-1$
    "BEGIN\n").append(// $NON-NLS-1$
    "SELECT param from pm1.g1 union select e1 from pm1.g1 order by param limit 2;\n").append(// $NON-NLS-1$
    "END");
    addProc(metadata, "sq1", procedure.toString(), new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }, new String[] { "param" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.sq1(1)";
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    helpTestProcess(plan, new List[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { "1" }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "First" }) }, 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 28 with FakeDataManager

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

the class TestProcedureProcessor method testEvaluatableLimit.

@Test
public void testEvaluatableLimit() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.example1();
    StringBuffer procedure = // $NON-NLS-1$
    new StringBuffer("CREATE VIRTUAL PROCEDURE \n").append(// $NON-NLS-1$
    "BEGIN\n").append(// $NON-NLS-1$
    "SELECT e1 from pm1.g1 limit param;\n").append(// $NON-NLS-1$
    "END");
    addProc(metadata, "sq1", procedure.toString(), new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }, new String[] { "param" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
    FakeDataManager dataMgr = exampleDataManager(metadata);
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.sq1(1)";
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    helpTestProcess(plan, new List[] { Arrays.asList(new Object[] { "First" }) }, dataMgr, // $NON-NLS-1$
    metadata);
    // $NON-NLS-1$
    userUpdateStr = "EXEC pm1.sq1(-1)";
    plan = getProcedurePlan(userUpdateStr, metadata);
    try {
        helpTestProcess(plan, new List[] { Arrays.asList(new Object[] { "First" }) }, dataMgr, // $NON-NLS-1$
        metadata);
        fail();
    } catch (QueryValidatorException e) {
    // shouldn't allow -1
    }
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) FakeDataManager(org.teiid.query.processor.FakeDataManager) QueryValidatorException(org.teiid.api.exception.query.QueryValidatorException) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 29 with FakeDataManager

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

the class TestProcedureProcessor method testDynamicCommandPositional.

@Test
public void testDynamicCommandPositional() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.example1();
    addProc(metadata, "sq2", // $NON-NLS-1$ //$NON-NLS-2$
    "CREATE VIRTUAL PROCEDURE BEGIN\n" + "execute string 'select e1 as x, e2 from pm1.g1'; END", new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING }, new String[] { "in" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.sq2('test')";
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    helpTestProcess(plan, new List[] { // $NON-NLS-1$ //$NON-NLS-2$
    Arrays.asList("First", "5"), // $NON-NLS-1$ //$NON-NLS-2$
    Arrays.asList("Second", "15"), Arrays.asList("Third", "51") }, dataMgr, // $NON-NLS-1$ //$NON-NLS-2$
    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 30 with FakeDataManager

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

the class TestProcedureProcessor method exampleDataManager2.

private FakeDataManager exampleDataManager2(QueryMetadataInterface metadata) throws TeiidException {
    FakeDataManager dataMgr = new FakeDataManager();
    dataMgr.registerTuples(metadata, "pm1.g1", new List[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { "First", Integer.valueOf(5), new Boolean(true), new Double(1.003) }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Second", Integer.valueOf(15), new Boolean(true), new Double(2.003) }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Third", Integer.valueOf(51), new Boolean(true), new Double(3.003) }) });
    dataMgr.registerTuples(metadata, "pm1.g2", new List[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { "First", Integer.valueOf(5), new Boolean(true), new Double(1.003) }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Second", Integer.valueOf(15), new Boolean(true), new Double(2.003) }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Third", Integer.valueOf(51), new Boolean(true), new Double(3.003) }) });
    dataMgr.registerTuples(metadata, "pm2.g1", new List[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { "First", Integer.valueOf(5), new Boolean(true), new Double(1.003) }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Second", Integer.valueOf(15), new Boolean(true), new Double(2.003) }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Third", Integer.valueOf(51), new Boolean(true), new Double(3.003) }) });
    dataMgr.registerTuples(metadata, "pm2.g2", new List[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { "First", Integer.valueOf(5), new Boolean(true), new Double(1.003) }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Second", Integer.valueOf(15), new Boolean(true), new Double(2.003) }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Third", Integer.valueOf(51), new Boolean(true), new Double(3.003) }) });
    return dataMgr;
}
Also used : FakeDataManager(org.teiid.query.processor.FakeDataManager)

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