Search in sources :

Example 26 with Options

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);
}
Also used : Options(org.teiid.query.util.Options) CommandContext(org.teiid.query.util.CommandContext) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) List(java.util.List) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 27 with Options

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) });
}
Also used : Options(org.teiid.query.util.Options) CommandContext(org.teiid.query.util.CommandContext) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) 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