use of org.teiid.query.util.Options in project teiid by teiid.
the class TestOrderByProcessing method testSortCollationInhibitsPush.
@Test
public void testSortCollationInhibitsPush() throws TeiidException {
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setSourceProperty(Capability.COLLATION_LOCALE, "foo");
// Create query
// $NON-NLS-1$
String sql = "select e1, e2 from pm1.g1 order by e2";
CommandContext cc = new CommandContext();
cc.setOptions(new Options().requireTeiidCollation(true));
// $NON-NLS-1$
ProcessorPlan plan = helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(caps), cc);
List[] expected = new List[] { Arrays.asList("a", 0), Arrays.asList("a", 1) };
HardcodedDataManager manager = new HardcodedDataManager();
manager.addData("SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_1", new List[] { Arrays.asList("a", 0), Arrays.asList("a", 1) });
helpProcess(plan, manager, expected);
// $NON-NLS-1$
sql = "select e1, e2 from pm1.g1 order by e1";
// $NON-NLS-1$
plan = helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(caps), cc);
expected = new List[] { Arrays.asList("a", 0), Arrays.asList("b", 1) };
manager = new HardcodedDataManager();
manager.addData("SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0", new List[] { Arrays.asList("b", 1), Arrays.asList("a", 0) });
helpProcess(plan, manager, expected);
}
use of org.teiid.query.util.Options in project teiid by teiid.
the class TestOrderByProcessing method testDefaultNullOrdering.
@Test
public void testDefaultNullOrdering() throws Exception {
// $NON-NLS-1$
String sql = "select e1 from pm1.g1 order by e1";
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
CommandContext cc = createCommandContext();
BufferManagerImpl bm = BufferManagerFactory.createBufferManager();
bm.setOptions(new Options().defaultNullOrder(NullOrder.FIRST));
cc.setBufferManager(bm);
ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, new DefaultCapabilitiesFinder(), cc);
HardcodedDataManager manager = new HardcodedDataManager(metadata);
manager.addData("SELECT g1.e1 FROM g1", new List[] { Arrays.asList("a"), Arrays.asList("b"), Arrays.asList((String) null) });
helpProcess(plan, cc, manager, new List[] { Arrays.asList((String) null), Arrays.asList("a"), Arrays.asList("b") });
plan = helpGetPlan(helpParse("select e1 from pm1.g1 order by e1 desc"), metadata, new DefaultCapabilitiesFinder(), cc);
helpProcess(plan, cc, manager, new List[] { Arrays.asList((String) null), Arrays.asList("b"), Arrays.asList("a") });
bm.getOptions().setDefaultNullOrder(NullOrder.LAST);
plan = helpGetPlan(helpParse("select e1 from pm1.g1 order by e1 desc"), metadata, new DefaultCapabilitiesFinder(), cc);
helpProcess(plan, cc, manager, new List[] { Arrays.asList("b"), Arrays.asList("a"), Arrays.asList((String) null) });
bm.getOptions().setDefaultNullOrder(NullOrder.HIGH);
plan = helpGetPlan(helpParse("select e1 from pm1.g1 order by e1"), metadata, new DefaultCapabilitiesFinder(), cc);
helpProcess(plan, cc, manager, new List[] { Arrays.asList("a"), Arrays.asList("b"), Arrays.asList((String) null) });
}
Aggregations