Search in sources :

Example 11 with HardcodedDataManager

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

the class TestMultiSourcePlanToProcessConverter method testMultiJoinImplicit.

@Test
public void testMultiJoinImplicit() 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") };
    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());
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 12 with HardcodedDataManager

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

the class TestMultiSourcePlanToProcessConverter method testNested.

@Test
public void testNested() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "select max(source_name), a from (SELECT a, source_name FROM MultiModel.Phys union all select b, source_name from MultiModel.phys1) as x group by a";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 2;
    final List<?>[] expected = new List<?>[] { Arrays.asList("b", 1) };
    final HardcodedDataManager dataMgr = new HardcodedDataManager();
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT v_0.c_0, MAX(v_0.c_1) FROM (SELECT g_1.a AS c_0, 'a' AS c_1 FROM MultiModel.Phys AS g_1 UNION ALL SELECT g_0.b AS c_0, 'a' AS c_1 FROM MultiModel.Phys1 AS g_0) AS v_0 GROUP BY v_0.c_0", new List<?>[] { Arrays.asList(1, "a") });
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT v_0.c_0, MAX(v_0.c_1) FROM (SELECT g_1.a AS c_0, 'b' AS c_1 FROM MultiModel.Phys AS g_1 UNION ALL SELECT g_0.b AS c_0, 'b' AS c_1 FROM MultiModel.Phys1 AS g_0) AS v_0 GROUP BY v_0.c_0", new List<?>[] { Arrays.asList(1, "b") });
    BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();
    bsc.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
    bsc.setCapabilitySupport(Capability.ROW_LIMIT, true);
    bsc.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
    bsc.setCapabilitySupport(Capability.QUERY_UNION, true);
    bsc.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
    bsc.setFunctionSupport(SourceSystemFunctions.CONCAT, true);
    helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB(), null, null, bsc);
}
Also used : 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 13 with HardcodedDataManager

use of org.teiid.query.processor.HardcodedDataManager 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 14 with HardcodedDataManager

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

the class TestMultiSourcePlanToProcessConverter method testMultiReplacementWithLimit.

@Test
public void testMultiReplacementWithLimit() throws Exception {
    final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT distinct a, b, source_name || a FROM MultiModel.Phys order by a limit 1";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 2;
    final List<?>[] expected = new List<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("e", "z", "be") };
    final HardcodedDataManager dataMgr = new HardcodedDataManager();
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT g_0.a, g_0.b, concat('a', g_0.a) FROM MultiModel.Phys AS g_0", new List<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("y", "z", "ay"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("x", "z", "ax") });
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT g_0.a, g_0.b, concat('b', g_0.a) FROM MultiModel.Phys AS g_0", new List<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("e", "z", "be"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("f", "z", "bf") });
    helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 15 with HardcodedDataManager

use of org.teiid.query.processor.HardcodedDataManager 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)

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