Search in sources :

Example 6 with Options

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

the class TestSubqueryPushdown method testSubqueryRewriteToJoinWithAggregate.

@Test
public void testSubqueryRewriteToJoinWithAggregate() throws Exception {
    CommandContext cc = new CommandContext();
    cc.setOptions(new Options().subqueryUnnestDefault(true));
    TestQueryRewriter.helpTestRewriteCommand("Select e1 from pm3.g1 where pm3.g1.e2 < (select max(e2) FROM pm1.g1 where pm3.g1.e1 = e1)", "SELECT e1 FROM pm3.g1, (SELECT MAX(e2) AS expr1, e1 FROM pm1.g1 GROUP BY e1) AS X__1 WHERE (pm3.g1.e2 < X__1.expr1) AND (pm3.g1.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 7 with Options

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

the class TestSubqueryPushdown method testSubqueryDoNotRewriteToJoin3.

@Test
public void testSubqueryDoNotRewriteToJoin3() 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 where pm3.g1.e3 <> e3)", "SELECT e1 FROM pm3.g1 WHERE e2 < SOME (SELECT MAX(pm1.g1.e2) FROM pm1.g1 WHERE e3 <> pm3.g1.e3)", RealMetadataFactory.example4(), cc);
    // should rewrite as we have an equi join predicate
    TestQueryRewriter.helpTestRewriteCommand("Select e1 from pm3.g1 where e2 < some (select pm1.g1.e2 FROM pm1.g1 where pm3.g1.e3 = e3)", "SELECT e1 FROM pm3.g1, (SELECT MAX(pm1.g1.e2) AS expr1, e3 FROM pm1.g1 GROUP BY e3) AS X__1 WHERE (e2 < X__1.expr1) AND (pm3.g1.e3 = X__1.e3)", RealMetadataFactory.example4(), cc);
}
Also used : Options(org.teiid.query.util.Options) CommandContext(org.teiid.query.util.CommandContext) Test(org.junit.Test)

Example 8 with Options

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

the class TestSubqueryPushdown method testSubqueryRewriteToJoinWithAggregate2.

@Test
public void testSubqueryRewriteToJoinWithAggregate2() throws Exception {
    CommandContext cc = new CommandContext();
    cc.setOptions(new Options().subqueryUnnestDefault(true));
    TestQueryRewriter.helpTestRewriteCommand("Select e1 from pm3.g1 where pm3.g1.e2 < (select max(e2) FROM pm1.g1 WHERE pm3.g1.e1 = e1 HAVING min(e3) < pm3.g1.e3)", "SELECT e1 FROM pm3.g1, (SELECT MAX(e2) AS expr1, e1, MIN(e3) AS expr3 FROM pm1.g1 GROUP BY e1) AS X__1 WHERE (X__1.expr3 < pm3.g1.e3) AND (pm3.g1.e2 < X__1.expr1) AND (pm3.g1.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 9 with Options

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

the class TestSubqueryPushdown method testSubqueryDoNotRewriteToJoin.

@Test
public void testSubqueryDoNotRewriteToJoin() throws Exception {
    CommandContext cc = new CommandContext();
    cc.setOptions(new Options().subqueryUnnestDefault(true));
    TestQueryRewriter.helpTestRewriteCommand("Select e1 from pm3.g1 where not exists (select pm1.g1.e1 FROM pm1.g1 where e1 = pm3.g1.e1)", "SELECT e1 FROM pm3.g1 WHERE NOT EXISTS (SELECT pm1.g1.e1 FROM pm1.g1 WHERE e1 = pm3.g1.e1 LIMIT 1)", RealMetadataFactory.example4(), cc);
}
Also used : Options(org.teiid.query.util.Options) CommandContext(org.teiid.query.util.CommandContext) Test(org.junit.Test)

Example 10 with Options

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

the class TestSubqueryPushdown method testSubqueryRewriteToJoinDistinct1.

// won't rewrite since we need distinct and don't have all equi join predicates
@Test
public void testSubqueryRewriteToJoinDistinct1() throws Exception {
    CommandContext cc = new CommandContext();
    cc.setOptions(new Options().subqueryUnnestDefault(true));
    TestQueryRewriter.helpTestRewriteCommand("Select e1 from pm1.g1 as x where exists (select pm1.g1.e1 FROM pm1.g1 where e1 = x.e1 and e2 < x.e2)", "SELECT e1 FROM pm1.g1 AS x WHERE EXISTS (SELECT pm1.g1.e1 FROM pm1.g1 WHERE (e1 = x.e1) AND (e2 < x.e2) LIMIT 1)", RealMetadataFactory.example1Cached(), cc);
}
Also used : Options(org.teiid.query.util.Options) CommandContext(org.teiid.query.util.CommandContext) 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