Search in sources :

Example 41 with HardcodedDataManager

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

the class TestSubqueryPushdown method testDeleteSubqueryCorrelatedCompensated.

@Test
public void testDeleteSubqueryCorrelatedCompensated() throws Exception {
    BasicSourceCapabilities bsc = getTypicalCapabilities();
    ProcessorPlan plan = // $NON-NLS-1$
    TestOptimizer.helpPlan(// $NON-NLS-1$
    "delete FROM pm1.g1 x where e1 = 'a' and e3 = (select e3 from pm1.g2 where e2 < x.e2)", RealMetadataFactory.example4(), null, new DefaultCapabilitiesFinder(bsc), new String[] {}, // $NON-NLS-1$
    ComparisonMode.EXACT_COMMAND_STRING);
    HardcodedDataManager hcdm = new HardcodedDataManager();
    hcdm.addData("SELECT g_0.e3, g_0.e2, g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 = 'a'", Arrays.asList(true, 1, 'a'));
    hcdm.addData("SELECT g_0.e3 FROM pm1.g2 AS g_0 WHERE g_0.e2 < 1", Arrays.asList(true));
    hcdm.addData("DELETE FROM pm1.g1 WHERE pm1.g1.e1 = 'a'", Arrays.asList(1));
    TestProcessor.helpProcess(plan, hcdm, null);
}
Also used : BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 42 with HardcodedDataManager

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

the class TestSubqueryPushdown method testAggNestedSubquery.

@Test
public void testAggNestedSubquery() throws Exception {
    // $NON-NLS-1$
    String sql = "SELECT g0.a, g0.b, (SELECT max((SELECT g2.a FROM m.z AS g2 WHERE g2.b = g1.a)) FROM m.y AS g1 WHERE g0.a = g1.b) FROM m.x AS g0";
    TransformationMetadata metadata = RealMetadataFactory.fromDDL("create foreign table x (" + " a string, " + " b string, " + " primary key (a)" + ") options (updatable true);" + "create foreign table y (" + " a string, " + " b string, " + " primary key (a)" + ") options (updatable true);" + "create foreign table z (" + " a string, " + " b string, " + " primary key (a)" + ") options (updatable true);", "x", "m");
    ProcessorPlan pp = TestProcessor.helpGetPlan(sql, metadata, TestOptimizer.getGenericFinder());
    HardcodedDataManager dataManager = new HardcodedDataManager();
    dataManager.addData("SELECT g_0.a, g_0.b FROM m.x AS g_0", Arrays.asList("a", "b"), Arrays.asList("a1", "b1"));
    dataManager.addData("SELECT g_0.a FROM m.y AS g_0 WHERE g_0.b = 'a'", Arrays.asList("a"));
    dataManager.addData("SELECT g_0.a FROM m.y AS g_0 WHERE g_0.b = 'a1'", Arrays.asList("b"));
    dataManager.addData("SELECT g_0.a FROM m.z AS g_0 WHERE g_0.b = 'b'", Arrays.asList("b2"));
    dataManager.addData("SELECT g_0.a FROM m.z AS g_0 WHERE g_0.b = 'a'", Arrays.asList("a2"));
    TestProcessor.helpProcess(pp, dataManager, new List[] { Arrays.asList("a", "b", "a2"), Arrays.asList("a1", "b1", "b2") });
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 43 with HardcodedDataManager

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

the class TestSubqueryPushdown method testCorrelatedOnly.

/**
 * Shows the uncorrelated subquery is evaluated ahead of time
 */
@Test
public void testCorrelatedOnly() throws Exception {
    BasicSourceCapabilities bsc = getTypicalCapabilities();
    bsc.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
    bsc.setCapabilitySupport(Capability.QUERY_SUBQUERIES_ONLY_CORRELATED, true);
    bsc.setCapabilitySupport(Capability.CRITERIA_EXISTS, true);
    ProcessorPlan plan = // $NON-NLS-1$
    TestOptimizer.helpPlan(// $NON-NLS-1$
    "SELECT 1 FROM bqt1.smalla where EXISTS (SELECT 'Y' FROM bqt1.mediuma)", RealMetadataFactory.exampleBQTCached(), null, new DefaultCapabilitiesFinder(bsc), new String[] { "SELECT 1 FROM BQT1.SmallA AS g_0 WHERE EXISTS (SELECT 'Y' FROM BQT1.MediumA AS g_0)" }, // $NON-NLS-1$
    ComparisonMode.EXACT_COMMAND_STRING);
    HardcodedDataManager hcdm = new HardcodedDataManager(false);
    TestProcessor.helpProcess(plan, hcdm, null);
    assertEquals("SELECT 'Y' FROM BQT1.MediumA AS g_0", hcdm.getCommandHistory().get(0).toString());
    assertEquals("SELECT 1 FROM BQT1.SmallA AS g_0", hcdm.getCommandHistory().get(1).toString());
}
Also used : BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 44 with HardcodedDataManager

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

the class TestUnionPlanning method testImplicitPartionwiseStarJoinMinimalColumns.

@Test
public void testImplicitPartionwiseStarJoinMinimalColumns() throws Exception {
    TransformationMetadata tm = partitionedStartSchema();
    String sql = "select combined_fact.id, combined_dim1.val, combined_dim2.val from combined_fact, combined_dim1, combined_dim2 where combined_fact.dim_id1 = combined_dim1.id and combined_fact.dim_id2 = combined_dim2.id";
    ProcessorPlan plan = // $NON-NLS-1$
    TestOptimizer.helpPlan(// $NON-NLS-1$
    sql, // $NON-NLS-1$
    tm, // $NON-NLS-1$
    null, // $NON-NLS-1$
    TestOptimizer.getGenericFinder(), new String[] { "SELECT g_0.id, g_1.val, g_2.val FROM source2.fact AS g_0, source2.dim1 AS g_1, source2.dim2 AS g_2 WHERE (g_0.dim_id1 = g_1.id) AND (g_0.dim_id2 = g_2.id)", "SELECT g_0.id, g_1.val, g_2.val FROM source1.fact AS g_0, source1.dim1 AS g_1, source1.dim2 AS g_2 WHERE (g_0.dim_id1 = g_1.id) AND (g_0.dim_id2 = g_2.id)" }, ComparisonMode.EXACT_COMMAND_STRING);
    HardcodedDataManager dataManager = new HardcodedDataManager();
    dataManager.addData("SELECT g_0.id, g_1.val, g_2.val FROM source1.fact AS g_0, source1.dim1 AS g_1, source1.dim2 AS g_2 WHERE (g_0.dim_id1 = g_1.id) AND (g_0.dim_id2 = g_2.id)", Arrays.asList(1, "abc", "def"));
    dataManager.addData("SELECT g_0.id, g_1.val, g_2.val FROM source2.fact AS g_0, source2.dim1 AS g_1, source2.dim2 AS g_2 WHERE (g_0.dim_id1 = g_1.id) AND (g_0.dim_id2 = g_2.id)", Arrays.asList(10, "2abc", "2def"));
    TestProcessor.helpProcess(plan, dataManager, new List[] { Arrays.asList(1, "abc", "def"), Arrays.asList(10, "2abc", "2def") });
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 45 with HardcodedDataManager

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

the class TestUnionPlanning method testPreserveGroupingOverUnion.

// TODO: enhancement for ordering over a partition
@Test
public void testPreserveGroupingOverUnion() throws TeiidComponentException, TeiidProcessingException {
    String sql = "select y.col2 from ( select x.col2, min(x.col1) as col1 from ( select 1 as col2, col1 from " + "(select 'a' as col1 UNION SELECT '' as col1) v1 union select 1 as col2, col1 from (select 'b' as col1 UNION SELECT '' as col1) v2) x group by x.col2 ) y";
    TransformationMetadata tm = RealMetadataFactory.example1Cached();
    ProcessorPlan plan = // $NON-NLS-1$
    TestOptimizer.helpPlan(// $NON-NLS-1$
    sql, // $NON-NLS-1$
    tm, // $NON-NLS-1$
    null, // $NON-NLS-1$
    new DefaultCapabilitiesFinder(), new String[] {}, ComparisonMode.EXACT_COMMAND_STRING);
    TestProcessor.helpProcess(plan, new HardcodedDataManager(), new List[] { Arrays.asList(1) });
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) 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