public Options getOptions() { if (this.globalState.options == null) { this.globalState.options = new Options(); } return this.globalState.options; }
private TupleBrowser createTupleBrower(Criteria condition, boolean direction) throws TeiidComponentException { IndexInfo ii = new IndexInfo(this, null, condition, null, true); ii.ordering = direction; return ii.createTupleBrowser(bm.getOptions().getDefaultNullOrder(), false); }
this.maxSessionBatchManagerSizeEstimate = this.options.getMaxSessionBufferSizeEstimate(); this.enforceMaxBatchManagerSizeEstimate = this.options.isEnforceSingleMaxBufferSizeEstimate();
options = new Options(); options.setAssumeMatchingCollation(false); options.setProperties(config.getProperties()); PropertiesUtils.setBeanProperties(options, options.getProperties(), "org.teiid", true); //$NON-NLS-1$
@Test public void testSubqueryRewriteToJoinWithAggregate() throws Exception { CommandContext cc = new CommandContext(); cc.setOptions(new Options().subqueryUnnestDefault(true)); TestQueryRewriter.helpTestRewriteCommand("Select e1 from pm3.g1 where pm3.g1.e2 < (select max(e2) FROM pm1.g1 where pm3.g1.e1 = e1)", "SELECT e1 FROM pm3.g1, (SELECT MAX(e2) AS expr1, e1 FROM pm1.g1 GROUP BY e1) AS X__1 WHERE (pm3.g1.e2 < X__1.expr1) AND (pm3.g1.e1 = X__1.e1)", RealMetadataFactory.example4(), cc); }
@Test public void testMultiJoinPartitionedExplicit() throws Exception { QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding(); final String userSql = "SELECT phys.a FROM MultiModel.Phys, MultiModel.phys1 where phys.a = phys1.b and Phys.source_name = phys1.source_name"; //$NON-NLS-1$ final String multiModel = "MultiModel"; //$NON-NLS-1$ final int sources = 2; final List<?>[] expected = new List<?>[] { Arrays.asList("a"), Arrays.asList("a"), }; final HardcodedDataManager dataMgr = new HardcodedDataManager(); dataMgr.addData("SELECT g_0.a FROM MultiModel.Phys AS g_0, MultiModel.Phys1 AS g_1 WHERE g_0.a = g_1.b", //$NON-NLS-1$ new List<?>[] { Arrays.asList("a")}); helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB(), null, new Options().implicitMultiSourceJoin(false)); }
/** * 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<?>[] {}); }
NullOrder teiidNullOrder = commandContext.getOptions().getDefaultNullOrder(); if (!supportsNullOrdering || (sourceNullOrder != teiidNullOrder && commandContext.getOptions().isPushdownDefaultNullOrder())) { correctNullOrdering(result, supportsNullOrdering, sourceNullOrder, commandContext.getOptions().getDefaultNullOrder());
return false; } else if (!context.getOptions().isAssumeMatchingCollation()) { return false;
CommandContext cc = createCommandContext(); BufferManagerImpl bm = BufferManagerFactory.createBufferManager(); bm.setOptions(new Options().defaultNullOrder(NullOrder.FIRST)); cc.setBufferManager(bm); ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, bm.getOptions().setDefaultNullOrder(NullOrder.LAST); bm.getOptions().setDefaultNullOrder(NullOrder.HIGH);
@Test public void testTracingEnabled() { TeiidTracingUtil ttu = new TeiidTracingUtil(); MockTracer tracer = new MockTracer(); ttu.setTracer(tracer); assertFalse(ttu.isTracingEnabled(new Options().tracingWithActiveSpanOnly(true), null)); }
@Test public void testSortCollationInhibitsPush() throws TeiidException { BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities(); caps.setSourceProperty(Capability.COLLATION_LOCALE, "foo"); // Create query String sql = "select e1, e2 from pm1.g1 order by e2"; //$NON-NLS-1$ CommandContext cc = new CommandContext(); cc.setOptions(new Options().requireTeiidCollation(true)); ProcessorPlan plan = helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(caps), cc); //$NON-NLS-1$ 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); sql = "select e1, e2 from pm1.g1 order by e1"; //$NON-NLS-1$ plan = helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(caps), cc); //$NON-NLS-1$ 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); }
bufferManager.setMaxReserveKB(10); bufferManager.setMaxActivePlans(10); bufferManager.setOptions(new Options().maxSessionBufferSizeEstimate(100000)); bufferManager.initialize(); CommandContext context = new CommandContext();
@Override public void visit(OrderBy obj) { String collation = null; try { collation = (String) CapabilitiesUtil.getProperty(Capability.COLLATION_LOCALE, modelID, metadata, capFinder); } catch(QueryMetadataException e) { handleException(new TeiidComponentException(e)); } catch(TeiidComponentException e) { handleException(e); } CommandContext commandContext = CommandContext.getThreadLocalContext(); if (collation != null && commandContext != null && commandContext.getOptions().isRequireTeiidCollation() && !collation.equals(DataTypeManager.COLLATION_LOCALE)) { for (OrderByItem symbol : obj.getOrderByItems()) { if (symbol.getSymbol().getType() == DataTypeManager.DefaultDataClasses.STRING || symbol.getSymbol().getType() == DataTypeManager.DefaultDataClasses.CLOB || symbol.getSymbol().getType() == DataTypeManager.DefaultDataClasses.CHAR) { //we require the collation to match markInvalid(obj, "source is not using the same collation as Teiid"); //$NON-NLS-1$ break; } } } }
sourceCount += NodeEditor.findAllNodes(accessNode2, NodeConstants.Types.SOURCE, NodeConstants.Types.SOURCE).size(); if (!context.getOptions().isAggressiveJoinGrouping() && accessMap.size() > 1 && joinType == JoinType.JOIN_INNER && (sourceCount > 2 && (accessNode1.hasProperty(Info.MAKE_DEP) || accessNode2.hasProperty(Info.MAKE_DEP)) || sourceCount > 3) && !canPushCrossJoin(metadata, accessNode1, accessNode2)) {
&& !isConformed(metadata, capFinder, (Set<Object>) childNode.getProperty(Info.CONFORMED_SOURCES), modelID, (Set<Object>) children.get(0).getProperty(Info.CONFORMED_SOURCES), accessModelID)) { return null; } else if ((multiSource || childNode.hasBooleanProperty(Info.IS_MULTI_SOURCE)) && !context.getOptions().isImplicitMultiSourceJoin()) {
/** * Same as above but using the system/option property * @throws TeiidComponentException * @throws TeiidProcessingException */ @Test public void testMergeJoinOrderNotPushed1() throws Exception { String sql = "select bqt1.smalla.intkey, bqt2.smalla.intkey " + "from bqt1.smalla inner join bqt2.smalla on (bqt2.smalla.stringkey = bqt1.smalla.stringkey)"; //$NON-NLS-1$ BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities(); bsc.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true); CommandContext cc = TestProcessor.createCommandContext(); cc.getOptions().setAssumeMatchingCollation(false); // Plan query ProcessorPlan plan = TestProcessor.helpGetPlan(TestOptimizer.helpGetCommand(sql, RealMetadataFactory.exampleBQTCached()), RealMetadataFactory.exampleBQTCached(), new DefaultCapabilitiesFinder(bsc), cc); HardcodedDataManager hdm = new HardcodedDataManager(); hdm.addData("SELECT g_0.StringKey, g_0.IntKey FROM BQT1.SmallA AS g_0", Arrays.asList("b", 1), Arrays.asList("a", 3)); hdm.addData("SELECT g_0.StringKey, g_0.IntKey FROM BQT2.SmallA AS g_0", Arrays.asList("c", 1), Arrays.asList("a", 2)); TestProcessor.helpProcess(plan, hdm, new List<?>[] {Arrays.asList(3, 2)}); }
this.maxBatchManagerSizeEstimate = (long)(.8*((((long)this.getMaxReserveKB())<<10) + max + cache.getMemoryBufferSpace())/Math.sqrt(maxActivePlans)); if (this.options != null) { this.maxSessionBatchManagerSizeEstimate = this.options.getMaxSessionBufferSizeEstimate();
options = new Options(); options.setAssumeMatchingCollation(false); options.setProperties(config.getProperties()); PropertiesUtils.setBeanProperties(options, options.getProperties(), "org.teiid", true); //$NON-NLS-1$
@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); }