Search in sources :

Example 81 with FakeDataManager

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

the class TestProcedureProcessor method testVirtualProcedure3.

@Test
public void testVirtualProcedure3() throws Exception {
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.vsp4()";
    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 82 with FakeDataManager

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

the class TestProcedureProcessor method testVirtualProcedureWithCreateAndDrop.

@Test
public void testVirtualProcedureWithCreateAndDrop() throws Exception {
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.vsp61()";
    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 83 with FakeDataManager

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

the class TestProcedureProcessor method testVirtualProcedure11.

@Test
public void testVirtualProcedure11() throws Exception {
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.vsp14()";
    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" }), // $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 84 with FakeDataManager

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

the class TestProcedureProcessor method testReferenceForwarding.

/**
 *  This is a slight variation of TestProcessor.testVariableInExecParam, where the proc wrapper can be
 *  removed after rewrite
 */
@Test
public void testReferenceForwarding() throws Exception {
    // Create query
    // $NON-NLS-1$
    String sql = "EXEC pm1.vsp49()";
    TransformationMetadata metadata = RealMetadataFactory.example1();
    addProc(metadata, "sq2", "CREATE VIRTUAL PROCEDURE BEGIN if (1 = 2) begin declare integer x = 1; end SELECT e1, e2 FROM pm1.g1 WHERE e1=pm1.sq2.in; END", new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER }, new String[] { "in" }, // $NON-NLS-1$
    new String[] { DataTypeManager.DefaultDataTypes.STRING });
    // Create expected results
    List[] expected = new List[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { "b", Integer.valueOf(2) }) };
    // Construct data manager with data
    FakeDataManager dataManager = new FakeDataManager();
    TestProcessor.sampleData1(dataManager);
    // Plan query
    ProcessorPlan plan = getProcedurePlan(sql, metadata);
    // Run query
    helpTestProcess(plan, expected, dataManager, 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 85 with FakeDataManager

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

the class TestProcedureProcessor method exampleDataManagerPm5.

private FakeDataManager exampleDataManagerPm5(QueryMetadataInterface metadata) throws TeiidException {
    FakeDataManager dataMgr = new FakeDataManager();
    dataMgr.registerTuples(metadata, "pm5.g3", new List[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { "First", new Short((short) 5), new Boolean(true), new Double(1.003) }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Second", new Short((short) 15), new Boolean(true), new Double(2.003) }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Third", new Short((short) 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