Search in sources :

Example 21 with Options

use of org.teiid.query.util.Options in project teiid by teiid.

the class TestSubqueryPushdown method testSubqueryRewriteToJoinExistsNoKey.

@Test
public void testSubqueryRewriteToJoinExistsNoKey() throws Exception {
    CommandContext cc = new CommandContext();
    cc.setOptions(new Options().subqueryUnnestDefault(true));
    TestQueryRewriter.helpTestRewriteCommand("Select e1 from pm1.g1 x where exists (select 1 FROM pm1.g2 where pm1.g2.e1 = x.e1)", "SELECT e1 FROM pm1.g1 AS x, (SELECT DISTINCT pm1.g2.e1 FROM pm1.g2) AS X__1 WHERE x.e1 = X__1.e1", RealMetadataFactory.example4(), cc);
}
Also used : Options(org.teiid.query.util.Options) CommandContext(org.teiid.query.util.CommandContext) Test(org.junit.Test)

Example 22 with Options

use of org.teiid.query.util.Options in project teiid by teiid.

the class TestSubqueryPushdown method testSubqueryRewriteToJoinGroupBy.

/**
 * Agg does not depend on cardinality
 */
@Test
public void testSubqueryRewriteToJoinGroupBy() throws Exception {
    CommandContext cc = new CommandContext();
    cc.setOptions(new Options().subqueryUnnestDefault(true));
    TestQueryRewriter.helpTestRewriteCommand("Select max(e1) from pm1.g1 as x where exists (select pm1.g1.e1 FROM pm1.g1 where e1 = x.e1) group by e2", "SELECT MAX(e1) FROM pm1.g1 AS x, (SELECT e1 FROM pm1.g1) AS X__1 WHERE x.e1 = X__1.e1 GROUP BY e2", RealMetadataFactory.example1Cached(), cc);
}
Also used : Options(org.teiid.query.util.Options) CommandContext(org.teiid.query.util.CommandContext) Test(org.junit.Test)

Example 23 with Options

use of org.teiid.query.util.Options in project teiid by teiid.

the class TestSubqueryPushdown method testSubqueryDoNotRewriteToJoin2.

@Test
public void testSubqueryDoNotRewriteToJoin2() throws Exception {
    CommandContext cc = new CommandContext();
    cc.setOptions(new Options().subqueryUnnestDefault(true));
    TestQueryRewriter.helpTestRewriteCommand("Select e1 from pm3.g1 where e2 < some (select pm1.g1.e2 FROM pm1.g1)", "SELECT e1 FROM pm3.g1 WHERE e2 < (SELECT MAX(X.e2) FROM (SELECT pm1.g1.e2 FROM pm1.g1) AS X)", RealMetadataFactory.example4(), cc);
}
Also used : Options(org.teiid.query.util.Options) CommandContext(org.teiid.query.util.CommandContext) Test(org.junit.Test)

Example 24 with Options

use of org.teiid.query.util.Options in project teiid by teiid.

the class TestOrderByProcessing method testNullOrdering2.

@Test
public void testNullOrdering2() throws Exception {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_ORDERBY_NULL_ORDERING, true);
    caps.setSourceProperty(Capability.QUERY_ORDERBY_DEFAULT_NULL_ORDER, NullOrder.FIRST);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    CommandContext cc = new CommandContext();
    cc.setOptions(new Options().pushdownDefaultNullOrder(true));
    ProcessorPlan plan = TestOptimizer.getPlan(TestOptimizer.helpGetCommand("select e1 from pm1.g1 order by e1 desc, e2 asc NULLS LAST", metadata, null), metadata, capFinder, null, true, cc);
    // $NON-NLS-1$
    TestOptimizer.checkAtomicQueries(new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0 DESC NULLS LAST, g_0.e2 NULLS LAST" }, plan);
    TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) Options(org.teiid.query.util.Options) CommandContext(org.teiid.query.util.CommandContext) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 25 with Options

use of org.teiid.query.util.Options in project teiid by teiid.

the class TestOrderByProcessing method testNullOrdering3.

/**
 * The engine will remove the null ordering if it's not needed
 * @throws Exception
 */
@Test
public void testNullOrdering3() throws Exception {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
    caps.setSourceProperty(Capability.QUERY_ORDERBY_DEFAULT_NULL_ORDER, NullOrder.HIGH);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    CommandContext cc = new CommandContext();
    cc.setOptions(new Options().pushdownDefaultNullOrder(true));
    ProcessorPlan plan = TestOptimizer.getPlan(TestOptimizer.helpGetCommand("select e1 from pm1.g1 order by e1 desc, e2 asc NULLS LAST", metadata, null), metadata, capFinder, null, true, cc);
    // $NON-NLS-1$
    TestOptimizer.checkAtomicQueries(new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0 DESC, g_0.e2" }, plan);
    TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) Options(org.teiid.query.util.Options) CommandContext(org.teiid.query.util.CommandContext) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Aggregations

Options (org.teiid.query.util.Options)27 Test (org.junit.Test)26 CommandContext (org.teiid.query.util.CommandContext)20 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)9 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)9 List (java.util.List)7 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)6 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)3 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)3 TeiidComponentException (org.teiid.core.TeiidComponentException)2 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)2 ArrayList (java.util.ArrayList)1 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)1 SessionMetadata (org.teiid.adminapi.impl.SessionMetadata)1 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)1 RequestMessage (org.teiid.client.RequestMessage)1 ResultsFuture (org.teiid.client.util.ResultsFuture)1 TupleBuffer (org.teiid.common.buffer.TupleBuffer)1 BufferManagerImpl (org.teiid.common.buffer.impl.BufferManagerImpl)1 TeiidProcessingException (org.teiid.core.TeiidProcessingException)1