Search in sources :

Example 76 with HardcodedDataManager

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

the class TestMultiSourcePlanToProcessConverter method testMultiReplacementWithOrderBy.

@Test
public void testMultiReplacementWithOrderBy() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT a, b, source_name || a FROM MultiModel.Phys order by a";
    // $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"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("f", "z", "bf"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("x", "z", "ax"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("y", "z", "ay") };
    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 77 with HardcodedDataManager

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

the class TestMultiSourcePlanToProcessConverter method testMultiDependentJoin.

@Test
public void testMultiDependentJoin() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT a.a FROM MultiModel.Phys a inner join MultiModel.Phys b makedep on (a.a = b.a) order by a";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 2;
    final List<?>[] expected = new List<?>[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { "x" }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "x" }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "x" }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "x" }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "y" }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "y" }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "y" }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "y" }) };
    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<?>[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { "x" }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "y" }) });
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT g_0.a FROM MultiModel.Phys AS g_0 WHERE g_0.a IN ('x', 'y')", new List<?>[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { "x" }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "y" }) });
    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 78 with HardcodedDataManager

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

the class TestMultiSourcePlanToProcessConverter method testSingleReplacement.

@Test
public void testSingleReplacement() throws Exception {
    final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT * FROM MultiModel.Phys WHERE SOURCE_NAME = 'a'";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 2;
    final List<?>[] expected = new List<?>[] { Arrays.asList(new Object[] { null, null }) };
    final HardcodedDataManager dataMgr = new MultiSourceDataManager();
    dataMgr.setMustRegisterCommands(false);
    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 79 with HardcodedDataManager

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

the class TestMultiSourcePlanToProcessConverter method testAggNotParitionedGroupBy.

@Test
public void testAggNotParitionedGroupBy() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT max(phys.a) FROM MultiModel.Phys group by b";
    // $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("y") };
    final HardcodedDataManager dataMgr = new HardcodedDataManager();
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT g_0.b, MAX(g_0.a) FROM MultiModel.Phys AS g_0 GROUP BY g_0.b", new List<?>[] { Arrays.asList("x", "y") });
    ProcessorPlan plan = helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
    TestOptimizer.checkNodeTypes(plan, new int[] { // Access
    3, // DependentAccess
    0, // DependentSelect
    0, // DependentProject
    0, // DupRemove
    0, // Grouping
    1, // NestedLoopJoinStrategy
    0, // MergeJoinStrategy
    0, // Null
    0, // PlanExecution
    0, // Project
    1, // Select
    0, // Sort
    0, // UnionAll
    1 });
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 80 with HardcodedDataManager

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

the class TestMultiSourcePlanToProcessConverter method testMultiReplacementWithProjectConstant.

@Test
public void testMultiReplacementWithProjectConstant() throws Exception {
    final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT a, b, source_name || a, '1' FROM MultiModel.Phys";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 2;
    final List<?>[] expected = new List<?>[] { Arrays.asList("x", "z", "ax", "1") };
    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("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<?>[] {});
    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)

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