Search in sources :

Example 76 with FakeDataManager

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

the class TestProcedureProcessor method testDynamicCommandWithVariableOnly.

@Test
public void testDynamicCommandWithVariableOnly() throws Exception {
    // Tests dynamic query with only a variable that represents thte entire dynamic query.
    TransformationMetadata metadata = RealMetadataFactory.example1();
    addProc(metadata, "sq1", // $NON-NLS-1$ //$NON-NLS-2$
    "CREATE VIRTUAL PROCEDURE BEGIN\n" + "DECLARE string VARIABLES.CRIT = 'select e1, e2 from pm5.g3 where e2=using.id'; execute string VARIABLES.CRIT USING ID = pm1.sq1.param; END", new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.SHORT }, new String[] { "param" }, // $NON-NLS-1$
    new String[] { DataTypeManager.DefaultDataTypes.SHORT });
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.sq1(convert(5,short))";
    FakeDataManager dataMgr = exampleDataManagerPm5(metadata);
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    // Create expected results
    // $NON-NLS-1$
    List[] expected = new List[] { Arrays.asList(new Object[] { "First", new Short((short) 5) }) };
    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 77 with FakeDataManager

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

the class TestProcedureProcessor method testCase174806.

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

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

the class TestProcedureProcessor method testVirtualProcedure19WithBlockedException.

@Test
public void testVirtualProcedure19WithBlockedException() throws Exception {
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.vsp23(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[] { "Second", Integer.valueOf(15) }) };
    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 79 with FakeDataManager

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

the class TestProcedureProcessor method testVirtualProcedure12.

@Test
public void testVirtualProcedure12() throws Exception {
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.vsp15()";
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    // Set up data
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    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[] { "Third", Integer.valueOf(51), new Boolean(true), new Double(3.003) }) });
    // Create expected results
    List[] expected = new List[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { "First" }), // $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 80 with FakeDataManager

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

the class TestProcedureProcessor method testInsertAfterCreate.

@Test
public void testInsertAfterCreate() 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$
    "\n  create local temporary table #temp (e1 string, e2 string);").append(// $NON-NLS-1$
    "\n  insert into #temp (e1) values ('a');").append(// $NON-NLS-1$
    "\n  insert into #temp (e2) values ('b');").append(// $NON-NLS-1$
    "SELECT e2 as e1 from #temp;\n").append(// $NON-NLS-1$
    "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(new Object[] { null }), Arrays.asList(new Object[] { "b" }) }, dataMgr, // $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)

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