Search in sources :

Example 16 with Options

use of org.teiid.query.util.Options in project teiid by teiid.

the class TestAggregateProcessing method testAggregateOrderByPushdown.

@Test()
public void testAggregateOrderByPushdown() throws Exception {
    // $NON-NLS-1$
    String sql = "SELECT string_agg(e1, ' ' order by e1) FROM pm1.g1";
    TransformationMetadata metadata = RealMetadataFactory.example1Cached();
    HardcodedDataManager hdm = new HardcodedDataManager(metadata);
    hdm.addData("SELECT STRING_AGG(g_0.e1, ' ' ORDER BY g_0.e1) FROM g1 AS g_0", Arrays.asList('a'));
    BasicSourceCapabilities bsc = TestAggregatePushdown.getAggregateCapabilities();
    bsc.setCapabilitySupport(Capability.QUERY_AGGREGATES_STRING, true);
    ProcessorPlan plan = TestProcessor.helpGetPlan(sql, metadata, new DefaultCapabilitiesFinder(bsc));
    TestProcessor.helpProcess(plan, TestProcessor.createCommandContext(), hdm, new List[] { Arrays.asList('a') });
    bsc.setSourceProperty(Capability.COLLATION_LOCALE, "foo");
    CommandContext cc = new CommandContext();
    cc.setOptions(new Options().requireTeiidCollation(true));
    CommandContext.pushThreadLocalContext(cc);
    try {
        plan = TestProcessor.helpGetPlan(helpParse(sql), metadata, new DefaultCapabilitiesFinder(bsc), cc);
        TestOptimizer.checkAtomicQueries(new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, plan);
    } finally {
        CommandContext.popThreadLocalContext();
    }
}
Also used : Options(org.teiid.query.util.Options) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) CommandContext(org.teiid.query.util.CommandContext) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 17 with Options

use of org.teiid.query.util.Options in project teiid by teiid.

the class TestBufferManagerImpl method testTupleBufferSessionMax.

@Test
public void testTupleBufferSessionMax() throws Exception {
    BufferManagerImpl bufferManager = new BufferManagerImpl();
    bufferManager.setCache(new MemoryStorageManager() {

        @Override
        public long getMaxStorageSpace() {
            return 64000;
        }
    });
    bufferManager.setMaxReserveKB(10);
    bufferManager.setMaxActivePlans(10);
    bufferManager.setOptions(new Options().maxSessionBufferSizeEstimate(100000));
    bufferManager.initialize();
    CommandContext context = new CommandContext();
    context.setSession(new SessionMetadata());
    CommandContext.pushThreadLocalContext(context);
    try {
        List<TupleBuffer> tupleBuffers = new ArrayList<TupleBuffer>();
        for (int i = 0; i < 36; i++) {
            TupleBuffer tb = bufferManager.createTupleBuffer(Arrays.asList(new ElementSymbol("x", null, String.class)), "x", TupleSourceType.PROCESSOR);
            try {
                for (int j = 0; j < 50; j++) {
                    tb.addTuple(Arrays.asList("a"));
                }
                tb.saveBatch();
                if (i % 2 == 0) {
                    tb.remove();
                }
            } catch (TeiidComponentException e) {
                assertEquals(34, i);
                return;
            }
            tupleBuffers.add(tb);
        }
    } finally {
        CommandContext.popThreadLocalContext();
    }
    fail();
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Options(org.teiid.query.util.Options) CommandContext(org.teiid.query.util.CommandContext) SessionMetadata(org.teiid.adminapi.impl.SessionMetadata) TupleBuffer(org.teiid.common.buffer.TupleBuffer) ArrayList(java.util.ArrayList) TeiidComponentException(org.teiid.core.TeiidComponentException) Test(org.junit.Test)

Example 18 with Options

use of org.teiid.query.util.Options in project teiid by teiid.

the class TestMultiSourcePlanToProcessConverter method testCountStar.

@Test
public void testCountStar() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT count(*) FROM MultiModel.Phys limit 100";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 2;
    final List<?>[] expected = new List<?>[] { Arrays.asList(4) };
    final HardcodedDataManager dataMgr = new HardcodedDataManager(metadata);
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT COUNT(*) FROM Phys AS g_0", new List<?>[] { Arrays.asList(2) });
    BasicSourceCapabilities bsc = TestAggregatePushdown.getAggregateCapabilities();
    bsc.setFunctionSupport("ifnull", true);
    helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB(), null, new Options().implicitMultiSourceJoin(false), bsc);
}
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)

Example 19 with Options

use of org.teiid.query.util.Options in project teiid by teiid.

the class TestMultiSourcePlanToProcessConverter method testNonPartitionedDistinct.

@Test
public void testNonPartitionedDistinct() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT distinct a FROM MultiModel.Phys";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 2;
    final List<?>[] expected = new List<?>[] { Arrays.asList("a") };
    final HardcodedDataManager dataMgr = new HardcodedDataManager(metadata);
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT DISTINCT g_0.a FROM Phys AS g_0", new List<?>[] { Arrays.asList("a") });
    BasicSourceCapabilities bsc = TestAggregatePushdown.getAggregateCapabilities();
    bsc.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
    helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB(), null, new Options().implicitMultiSourceJoin(false), bsc);
}
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)

Example 20 with Options

use of org.teiid.query.util.Options in project teiid by teiid.

the class TestSubqueryPushdown method testSubqueryRewriteToJoinWithGroupingExpression.

@Test
public void testSubqueryRewriteToJoinWithGroupingExpression() throws Exception {
    CommandContext cc = new CommandContext();
    cc.setOptions(new Options().subqueryUnnestDefault(true));
    TestQueryRewriter.helpTestRewriteCommand("Select distinct e1 from pm3.g1 where exists (select 1 FROM pm1.g1 group by e4 || 'x' HAVING min(e3) || (e4 || 'x') = pm3.g1.e3)", "SELECT DISTINCT e1 FROM pm3.g1, (SELECT MIN(e3) AS expr1, concat(convert(e4, string), 'x') AS expr2, concat(convert(MIN(e3), string), concat(convert(e4, string), 'x')) AS expr FROM pm1.g1 GROUP BY concat(convert(e4, string), 'x')) AS X__1 WHERE convert(pm3.g1.e3, string) = X__1.expr", RealMetadataFactory.example4(), cc);
}
Also used : Options(org.teiid.query.util.Options) CommandContext(org.teiid.query.util.CommandContext) Test(org.junit.Test)

Aggregations

Options (org.teiid.query.util.Options)27 Test (org.junit.Test)26 CommandContext (org.teiid.query.util.CommandContext)20 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)9 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)9 List (java.util.List)7 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)6 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)3 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)3 TeiidComponentException (org.teiid.core.TeiidComponentException)2 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)2 ArrayList (java.util.ArrayList)1 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)1 SessionMetadata (org.teiid.adminapi.impl.SessionMetadata)1 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)1 RequestMessage (org.teiid.client.RequestMessage)1 ResultsFuture (org.teiid.client.util.ResultsFuture)1 TupleBuffer (org.teiid.common.buffer.TupleBuffer)1 BufferManagerImpl (org.teiid.common.buffer.impl.BufferManagerImpl)1 TeiidProcessingException (org.teiid.core.TeiidProcessingException)1