Search in sources :

Example 86 with HardcodedDataManager

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

the class TestCallableStatement method testInputExpression.

@Test
public void testInputExpression() throws Exception {
    // $NON-NLS-1$
    String sql = "{call pm2.spTest8(1, ?)}";
    List[] expected = new List[1];
    expected[0] = Arrays.asList(null, null, 0);
    HardcodedDataManager dataManager = new HardcodedDataManager();
    dataManager.addData("EXEC pm2.spTest8(1)", expected);
    helpProcess(sql, null, expected, dataManager);
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 87 with HardcodedDataManager

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

the class TestCallableStatement method testMissingInput.

@Test
public void testMissingInput() throws Exception {
    // $NON-NLS-1$
    String sql = "{? = call pm4.spTest9()}";
    try {
        TestPreparedStatement.helpTestProcessing(sql, Collections.EMPTY_LIST, null, new HardcodedDataManager(), RealMetadataFactory.exampleBQTCached(), true, RealMetadataFactory.exampleBQTVDB());
        fail();
    } catch (QueryResolverException e) {
        // $NON-NLS-1$
        assertEquals("TEIID30089 Required parameter 'pm4.spTest9.inkey' has no value was set or is an invalid parameter.", e.getMessage());
    }
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) QueryResolverException(org.teiid.api.exception.query.QueryResolverException) Test(org.junit.Test)

Example 88 with HardcodedDataManager

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

the class TestCallableStatement method testOutParameter.

@Test
public void testOutParameter() throws Exception {
    // $NON-NLS-1$
    String sql = "{call pm2.spTest8(?, ?)}";
    List values = new ArrayList();
    values.add(2);
    List[] expected = new List[1];
    expected[0] = Arrays.asList(null, null, 1);
    HardcodedDataManager dataManager = new HardcodedDataManager();
    dataManager.addData("EXEC pm2.spTest8(2)", expected);
    helpProcess(sql, values, expected, dataManager);
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 89 with HardcodedDataManager

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

the class TestCallableStatement method testReturnParameter.

@Test
public void testReturnParameter() throws Exception {
    // $NON-NLS-1$
    String sql = "{? = call pm4.spTest9(inkey=>?)}";
    List values = new ArrayList();
    values.add(1);
    List[] expected = new List[1];
    expected[0] = Arrays.asList(1);
    HardcodedDataManager dataManager = new HardcodedDataManager();
    dataManager.addData("? = EXEC pm4.spTest9(1)", expected);
    helpProcess(sql, values, expected, dataManager);
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 90 with HardcodedDataManager

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

the class TestOptimizer method testScalarSubQueryInSelect.

/**
 * Try substituting "is not null" for "exists" criteria
 */
@Test
public void testScalarSubQueryInSelect() throws TeiidComponentException, TeiidProcessingException {
    // $NON-NLS-1$
    String sql = "select intkey, case when (select stringkey from bqt1.smallb) is not null then 'nuge' end as a from vqt.smalla";
    ProcessorPlan plan = helpPlan(sql, RealMetadataFactory.exampleBQTCached(), new String[] { "SELECT g_0.IntKey, CASE WHEN (SELECT g_0.StringKey FROM BQT1.SmallB AS g_0) IS NOT NULL THEN 'nuge' END FROM BQT1.SmallA AS g_0" }, // $NON-NLS-1$
    ComparisonMode.EXACT_COMMAND_STRING);
    checkNodeTypes(plan, new int[] { // Access
    1, // DependentAccess
    0, // DependentSelect
    0, // DependentProject
    0, // DupRemove
    0, // Grouping
    0, // Join
    0, // MergeJoin
    0, // Null
    0, // PlanExecution
    0, // Project
    0, // Select
    0, // Sort
    0, // UnionAll
    0 });
    HardcodedDataManager hdm = new HardcodedDataManager();
    hdm.addData("SELECT g_0.StringKey FROM BQT1.SmallB AS g_0", Arrays.asList("a"));
    hdm.addData("SELECT g_0.IntKey FROM BQT1.SmallA AS g_0", Arrays.asList(1));
    TestProcessor.helpProcess(plan, hdm, new List[] { Arrays.asList(1, "nuge") });
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Aggregations

HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)140 Test (org.junit.Test)134 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)97 List (java.util.List)75 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)63 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)53 ArrayList (java.util.ArrayList)44 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)42 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)29 CommandContext (org.teiid.query.util.CommandContext)19 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)14 Options (org.teiid.query.util.Options)6 BufferManagerImpl (org.teiid.common.buffer.impl.BufferManagerImpl)5 RegisterRequestParameter (org.teiid.query.processor.RegisterRequestParameter)4 Command (org.teiid.query.sql.lang.Command)4 TupleSource (org.teiid.common.buffer.TupleSource)3 Insert (org.teiid.query.sql.lang.Insert)3 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)2 TeiidProcessingException (org.teiid.core.TeiidProcessingException)2 TeiidSQLException (org.teiid.jdbc.TeiidSQLException)2