Search in sources :

Example 1 with Options

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

the class TestMultiSourcePlanToProcessConverter method testGroupByCountPushdownMultiSource.

@Test
public void testGroupByCountPushdownMultiSource() throws Exception {
    String userSql = "SELECT s.e1, m.e1, COUNT(*) FROM pm1.g1 AS s INNER JOIN pm2.g2 AS m ON s.e2 = m.e2 GROUP BY s.e1, m.e1";
    HardcodedDataManager hdm = new HardcodedDataManager();
    hdm.addData("SELECT g_0.e2, COUNT(*) FROM pm1.g1 AS g_0 GROUP BY g_0.e2", Arrays.asList(1, 2));
    hdm.addData("SELECT g_0.e2 AS c_0, g_0.e1 AS c_1 FROM pm2.g2 AS g_0 ORDER BY c_0", Arrays.asList(1, "other"));
    BasicSourceCapabilities bsc = TestAggregatePushdown.getAggregateCapabilities();
    bsc.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, false);
    bsc.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, false);
    TransformationMetadata metadata = RealMetadataFactory.example1Cached();
    final List<?>[] expected = new List<?>[] { Arrays.asList("a", "other", 2), Arrays.asList("b", "other", 2) };
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("exampleMultiBinding");
    vdb.setVersion(1);
    ModelMetaData model = new ModelMetaData();
    model.setName("pm1");
    model.setModelType(Model.Type.PHYSICAL);
    model.setVisible(true);
    model.setSupportsMultiSourceBindings(true);
    model.addProperty(MultiSourceMetadataWrapper.MULTISOURCE_COLUMN_NAME, "e1");
    vdb.addModel(model);
    helpTestMultiSourcePlan(metadata, userSql, "pm1", 2, hdm, expected, vdb, null, new Options().implicitMultiSourceJoin(false), bsc);
}
Also used : Options(org.teiid.query.util.Options) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) List(java.util.List) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Example 2 with Options

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

the class TestMultiSourcePlanToProcessConverter method testUnsupportedPredicate.

@Test
public void testUnsupportedPredicate() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT phys.a FROM MultiModel.Phys where Phys.source_name like 'a%'";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 2;
    final List<?>[] expected = new List<?>[] { Arrays.asList("a") };
    final HardcodedDataManager dataMgr = new HardcodedDataManager();
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT MultiModel.Phys.a FROM MultiModel.Phys", new List<?>[] { Arrays.asList("a") });
    helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB(), null, new Options().implicitMultiSourceJoin(false), new BasicSourceCapabilities());
    assertEquals(3, dataMgr.getCommandHistory().size());
}
Also used : Options(org.teiid.query.util.Options) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 3 with Options

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

the class TestMultiSourcePlanToProcessConverter method testMultiJoinPartitionedExplicit.

@Test
public void testMultiJoinPartitionedExplicit() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT phys.a FROM MultiModel.Phys, MultiModel.phys1 where phys.a = phys1.b and Phys.source_name = phys1.source_name";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 2;
    final List<?>[] expected = new List<?>[] { Arrays.asList("a"), Arrays.asList("a") };
    final HardcodedDataManager dataMgr = new HardcodedDataManager();
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT g_0.a FROM MultiModel.Phys AS g_0, MultiModel.Phys1 AS g_1 WHERE g_0.a = g_1.b", new List<?>[] { Arrays.asList("a") });
    helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB(), null, new Options().implicitMultiSourceJoin(false));
}
Also used : Options(org.teiid.query.util.Options) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 4 with Options

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

the class TestMultiSourcePlanToProcessConverter method testMultiJoinNotImplicit.

/**
 * With implicit join turned off, we now get the join of the union of the source queries.
 */
@Test
public void testMultiJoinNotImplicit() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT phys.a FROM MultiModel.Phys, MultiModel.phys1 where phys.a = phys1.b";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 2;
    final List<?>[] expected = new List<?>[] { Arrays.asList("a"), Arrays.asList("a"), Arrays.asList("a"), Arrays.asList("a") };
    final HardcodedDataManager dataMgr = new HardcodedDataManager();
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT g_0.a FROM MultiModel.Phys AS g_0", new List<?>[] { Arrays.asList("a") });
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT g_0.b FROM MultiModel.Phys1 AS g_0", new List<?>[] { Arrays.asList("a") });
    helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB(), null, new Options().implicitMultiSourceJoin(false));
}
Also used : Options(org.teiid.query.util.Options) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 5 with Options

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

the class TestSubqueryPushdown method testSubqueryRewriteToJoinDistinct.

@Test
public void testSubqueryRewriteToJoinDistinct() throws Exception {
    CommandContext cc = new CommandContext();
    cc.setOptions(new Options().subqueryUnnestDefault(true));
    TestQueryRewriter.helpTestRewriteCommand("Select distinct e1 from pm1.g1 as x where exists (select pm1.g1.e1 FROM pm1.g1 where e1 = x.e1)", "SELECT DISTINCT e1 FROM pm1.g1 AS x, (SELECT e1 FROM pm1.g1) AS X__1 WHERE x.e1 = X__1.e1", 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