Search in sources :

Example 16 with QueryMetadataInterface

use of org.teiid.query.metadata.QueryMetadataInterface 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 17 with QueryMetadataInterface

use of org.teiid.query.metadata.QueryMetadataInterface 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 18 with QueryMetadataInterface

use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.

the class TestMultiSourcePlanToProcessConverter method testInsertMatching.

@Test
public void testInsertMatching() throws Exception {
    final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "INSERT INTO MultiModel.Phys(a, SOURCE_NAME) VALUES ('a', 'a')";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 3;
    final List<?>[] expected = new List<?>[] { Arrays.asList(1) };
    final MultiSourceDataManager dataMgr = new MultiSourceDataManager();
    dataMgr.setMustRegisterCommands(true);
    // $NON-NLS-1$
    dataMgr.addData("INSERT INTO MultiModel.Phys (a) VALUES ('a')", new List<?>[] { Arrays.asList(1) });
    helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
}
Also used : List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 19 with QueryMetadataInterface

use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.

the class TestMultiSourcePlanToProcessConverter method testProcedure.

@Test
public void testProcedure() throws Exception {
    final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "exec MultiModel.proc('b', 'a')";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 3;
    final List<?>[] expected = new List<?>[] { Arrays.asList(1) };
    final MultiSourceDataManager dataMgr = new MultiSourceDataManager();
    dataMgr.setMustRegisterCommands(true);
    // $NON-NLS-1$
    dataMgr.addData("EXEC MultiModel.proc('b')", new List<?>[] { Arrays.asList(1) });
    helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
}
Also used : List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 20 with QueryMetadataInterface

use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.

the class TestMultiSourcePlanToProcessConverter method testMultiReplacement.

@Test
public void testMultiReplacement() throws Exception {
    final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT * FROM MultiModel.Phys";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 3;
    final List<?>[] expected = new List<?>[] { Arrays.asList(new Object[] { null, null }), Arrays.asList(new Object[] { null, null }), Arrays.asList(new Object[] { null, null }) };
    final ProcessorDataManager dataMgr = new MultiSourceDataManager();
    helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
}
Also used : ProcessorDataManager(org.teiid.query.processor.ProcessorDataManager) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Aggregations

QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)507 Test (org.junit.Test)464 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)210 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)189 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)177 List (java.util.List)126 Command (org.teiid.query.sql.lang.Command)90 ArrayList (java.util.ArrayList)72 FakeDataManager (org.teiid.query.processor.FakeDataManager)48 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)43 BigInteger (java.math.BigInteger)41 CommandContext (org.teiid.query.util.CommandContext)37 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)29 AnalysisRecord (org.teiid.query.analysis.AnalysisRecord)16 MetadataStore (org.teiid.metadata.MetadataStore)12 Schema (org.teiid.metadata.Schema)11 BatchedUpdateCommand (org.teiid.query.sql.lang.BatchedUpdateCommand)11 TeiidException (org.teiid.core.TeiidException)10 TeiidProcessingException (org.teiid.core.TeiidProcessingException)10 CapabilitiesFinder (org.teiid.query.optimizer.capabilities.CapabilitiesFinder)10