/** * Join processing is insensitive to the null ordering */ @Test public void testNullOrderingJoin() throws Exception { BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities(); caps.setCapabilitySupport(Capability.QUERY_ORDERBY_NULL_ORDERING, true); caps.setSourceProperty(Capability.QUERY_ORDERBY_DEFAULT_NULL_ORDER, NullOrder.UNKNOWN); DefaultCapabilitiesFinder capFinder = new DefaultCapabilitiesFinder(caps); //$NON-NLS-1$ QueryMetadataInterface metadata = RealMetadataFactory.example1Cached(); CommandContext cc = new CommandContext(); cc.setOptions(new Options().pushdownDefaultNullOrder(true)); ProcessorPlan plan = TestOptimizer.getPlan(TestOptimizer.helpGetCommand("select pm1.g1.e1, pm2.g1.e3 from /*+ makedep */ pm1.g1, pm2.g1 where pm1.g1.e2 = pm2.g1.e2", metadata), metadata, capFinder, null, true, cc); HardcodedDataManager dataManager = new HardcodedDataManager(metadata, cc, caps); dataManager.addData("SELECT g_0.e2 AS c_0, g_0.e3 AS c_1 FROM g1 AS g_0 ORDER BY c_0", new List<?>[] {}); TestProcessor.helpProcess(plan, dataManager, new List<?>[] {}); }
@Test public void testNullOrdering2() throws Exception { FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder(); BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities(); caps.setCapabilitySupport(Capability.QUERY_ORDERBY_NULL_ORDERING, true); caps.setSourceProperty(Capability.QUERY_ORDERBY_DEFAULT_NULL_ORDER, NullOrder.FIRST); capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$ QueryMetadataInterface metadata = RealMetadataFactory.example1Cached(); CommandContext cc = new CommandContext(); cc.setOptions(new Options().pushdownDefaultNullOrder(true)); ProcessorPlan plan = TestOptimizer.getPlan(TestOptimizer.helpGetCommand("select e1 from pm1.g1 order by e1 desc, e2 asc NULLS LAST", metadata), metadata, capFinder, null, true, cc); TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN); HardcodedDataManager dataManager = new HardcodedDataManager(metadata, cc, caps); dataManager.addData("SELECT g_0.e1 AS c_0 FROM g1 AS g_0 ORDER BY c_0 DESC NULLS LAST, g_0.e2 NULLS LAST", new List<?>[] {}); TestProcessor.helpProcess(plan, dataManager, new List<?>[] {}); }
/** * The engine will remove the null ordering if it's not needed * @throws Exception */ @Test public void testNullOrdering3() throws Exception { FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder(); BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities(); caps.setSourceProperty(Capability.QUERY_ORDERBY_DEFAULT_NULL_ORDER, NullOrder.HIGH); capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$ QueryMetadataInterface metadata = RealMetadataFactory.example1Cached(); CommandContext cc = new CommandContext(); cc.setOptions(new Options().pushdownDefaultNullOrder(true)); ProcessorPlan plan = TestOptimizer.getPlan(TestOptimizer.helpGetCommand("select e1 from pm1.g1 order by e1 desc, e2 asc NULLS LAST", metadata), metadata, capFinder, null, true, cc); TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN); HardcodedDataManager dataManager = new HardcodedDataManager(metadata, cc, caps); dataManager.addData("SELECT g_0.e1 AS c_0 FROM g1 AS g_0 ORDER BY c_0 DESC, g_0.e2", new List<?>[] {}); TestProcessor.helpProcess(plan, dataManager, new List<?>[] {}); }
private void helpTestNullOrdering(String sql, String result) throws TeiidComponentException, TeiidProcessingException { FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder(); BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities(); caps.setCapabilitySupport(Capability.QUERY_ORDERBY_NULL_ORDERING, true); caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true); caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_STRING, true); caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true); caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true); caps.setCapabilitySupport(Capability.WINDOW_FUNCTION_ORDER_BY_AGGREGATES, true); caps.setCapabilitySupport(Capability.ELEMENTARY_OLAP, true); caps.setCapabilitySupport(Capability.ROW_LIMIT, true); caps.setSourceProperty(Capability.QUERY_ORDERBY_DEFAULT_NULL_ORDER, NullOrder.UNKNOWN); capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$ QueryMetadataInterface metadata = RealMetadataFactory.example1Cached(); CommandContext cc = new CommandContext(); cc.setOptions(new Options().pushdownDefaultNullOrder(true)); ProcessorPlan plan = TestOptimizer.getPlan(TestOptimizer.helpGetCommand(sql, metadata), metadata, capFinder, null, true, cc); TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN); HardcodedDataManager dataManager = new HardcodedDataManager(metadata, cc, caps); dataManager.addData(result, new List<?>[] {}); TestProcessor.helpProcess(plan, dataManager, new List<?>[] {}); }