Search in sources :

Example 6 with HardcodedDataManager

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

the class TestTupleSourceCache method testNodeId.

@Test
public void testNodeId() throws Exception {
    TupleSourceCache tsc = new TupleSourceCache();
    HardcodedDataManager pdm = new HardcodedDataManager() {

        @Override
        public TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject) throws TeiidComponentException {
            assertEquals(1, parameterObject.nodeID);
            return Mockito.mock(TupleSource.class);
        }
    };
    CommandContext context = TestProcessor.createCommandContext();
    BufferManagerImpl bufferMgr = BufferManagerFactory.createBufferManager();
    Command command = new Insert();
    RegisterRequestParameter parameterObject = new RegisterRequestParameter("z", 1, 1);
    parameterObject.info = new RegisterRequestParameter.SharedAccessInfo();
    tsc.getSharedTupleSource(context, command, "x", parameterObject, bufferMgr, pdm);
}
Also used : CommandContext(org.teiid.query.util.CommandContext) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) Command(org.teiid.query.sql.lang.Command) Insert(org.teiid.query.sql.lang.Insert) RegisterRequestParameter(org.teiid.query.processor.RegisterRequestParameter) Test(org.junit.Test)

Example 7 with HardcodedDataManager

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

the class TestTupleSourceCache method testJoinProcessingWithNestedSubquery.

@Test
public void testJoinProcessingWithNestedSubquery() throws Exception {
    HardcodedDataManager pdm = new HardcodedDataManager();
    pdm.setBlockOnce(true);
    String sql = "select e1 from (select e1, e2 from pm1.g1 where (select e3 from pm2.g1) = true) x inner join (select e2 from pm1.g2) y on x.e2 = y.e2 " + "union all " + "select e1 from (select e1, e2 from pm1.g1 where (select e3 from pm2.g1) = true) x inner join (select e2 from pm1.g2) y on x.e2 = y.e2";
    pdm.addData("SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1", Arrays.asList(1, "a"));
    pdm.addData("SELECT pm1.g2.e2 FROM pm1.g2", Arrays.asList(1));
    pdm.addData("SELECT pm2.g1.e3 FROM pm2.g1", Arrays.asList(true));
    ProcessorPlan plan = TestProcessor.helpGetPlan(sql, RealMetadataFactory.example1Cached());
    TestProcessor.helpProcess(plan, pdm, new List<?>[] { Arrays.asList("a"), Arrays.asList("a") });
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 8 with HardcodedDataManager

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

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

the class TestMultiSourcePlanToProcessConverter method testAggParitioned.

@Test
public void testAggParitioned() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT max(phys.a), source_name FROM MultiModel.Phys group by Phys.source_name";
    // $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", "a"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("y", "b") };
    final HardcodedDataManager dataMgr = new HardcodedDataManager();
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT MAX(g_0.a) FROM MultiModel.Phys AS g_0", new List<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("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
    0, // 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 10 with HardcodedDataManager

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

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