Search in sources :

Example 21 with QueryMetadataInterface

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

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

the class TestMultiSourcePlanToProcessConverter method testSingleReplacementInDynamicCommand.

@Test
public void testSingleReplacementInDynamicCommand() throws Exception {
    final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "exec Virt.sq1('a')";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 3;
    final List<?>[] expected = new List<?>[] { 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)

Example 23 with QueryMetadataInterface

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

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

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

the class TestMultiSourcePlanToProcessConverter method testInsertNotMatching.

@Test
public void testInsertNotMatching() throws Exception {
    final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "INSERT INTO MultiModel.Phys(a, SOURCE_NAME) VALUES ('a', 'x')";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 3;
    final List<?>[] expected = new List<?>[] { Arrays.asList(0) };
    final MultiSourceDataManager dataMgr = new MultiSourceDataManager();
    dataMgr.setMustRegisterCommands(true);
    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)

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