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();
}
}
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();
}
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);
}
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);
}
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);
}
Aggregations