Search in sources :

Example 91 with FakeDataManager

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

the class TestProcedureProcessor method testVirtualProcedure9.

@Test
public void testVirtualProcedure9() throws Exception {
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.vsp10(51)";
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    // Create expected results
    List[] expected = new List[] {};
    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 92 with FakeDataManager

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

the class TestProcedureProcessor method testRemovalOfNonJoinCritWithReference2.

/**
 * Test the use of a procedure variable in the criteria of a LEFT OUTER
 * JOIN which will be optimized out as non-JOIN criteria.
 * <p>
 * This test case verifies that the procedure variable will not be pushed
 * to the data manager when a federated source JOIN is performed and the
 * physical source supports all capabilities.
 *
 * @throws Exception
 */
@Test
public void testRemovalOfNonJoinCritWithReference2() throws Exception {
    // $NON-NLS-1$
    String proc = "";
    // $NON-NLS-1$
    String sql = "";
    sql += // $NON-NLS-1$
    "SELECT " + // $NON-NLS-1$
    "	pm1.g1.e1 AS pm1g1e1, " + // $NON-NLS-1$
    "	pm2.g2.e1 AS pm2g2e1, " + // $NON-NLS-1$
    "	pm1.g1.e2 AS pm1g1e2, " + // $NON-NLS-1$
    "	pm2.g2.e2 AS pm2g2e2 " + // $NON-NLS-1$
    "FROM " + // $NON-NLS-1$
    "	pm1.g1	" + // $NON-NLS-1$
    "LEFT OUTER JOIN pm2.g2 " + // $NON-NLS-1$
    "	ON pm1.g1.e1 = pm2.g2.e1 " + // $NON-NLS-1$
    "	AND pm2.g2.e2 = VARIABLES.myVar ";
    proc += // $NON-NLS-1$
    "CREATE VIRTUAL PROCEDURE " + // $NON-NLS-1$
    "BEGIN " + // $NON-NLS-1$
    "   declare integer myVar = 5;" + "   " + sql + // $NON-NLS-1$ //$NON-NLS-2$
    ";" + // $NON-NLS-1$
    "END";
    TransformationMetadata metadata = RealMetadataFactory.example1();
    addProc(metadata, "sq1", proc, new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER }, new String[0], new String[0]);
    // $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[] { // $NON-NLS-1$ //$NON-NLS-2$
    Arrays.asList(new Object[] { "First", "First", Integer.valueOf(5), Integer.valueOf(5) }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Second", null, Integer.valueOf(15), null }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "Third", null, Integer.valueOf(51), null }) };
    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 93 with FakeDataManager

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

the class TestProcedureProcessor method testVirtualProcedure18.

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

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

the class TestProcedureProcessor method testEvaluatableSelectWithOrderBy.

@Test
public void testEvaluatableSelectWithOrderBy() 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 order by param limit 1;\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[] { Arrays.asList(new Object[] { "1" }) }, 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)

Example 95 with FakeDataManager

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

the class TestProcedureProcessor method testDefect16649_1.

@Test
public void testDefect16649_1() throws Exception {
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.vsp38()";
    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[] { "Second" }) };
    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)

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