public boolean planQuery(Collection<GroupSymbol> leftGroups, boolean requireDistinct, PlannedResult plannedResult) throws QueryMetadataException, TeiidComponentException { if ((plannedResult.query.getLimit() != null && !plannedResult.query.getLimit().isImplicit()) || plannedResult.query.getFrom() == null) { return false;
public boolean planQuery(Collection<GroupSymbol> leftGroups, boolean requireDistinct, PlannedResult plannedResult) throws QueryMetadataException, TeiidComponentException { if ((plannedResult.query.getLimit() != null && !plannedResult.query.getLimit().isImplicit()) || plannedResult.query.getFrom() == null) { return false;
private static PlanNode attachTupleLimit(PlanNode plan, Limit limit, PlanHints hints) { hints.hasLimit = true; PlanNode limitNode = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT); boolean attach = false; if (limit.getOffset() != null) { limitNode.setProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT, limit.getOffset()); attach = true; } if (limit.getRowLimit() != null) { limitNode.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, limit.getRowLimit()); attach = true; } if (attach) { if (limit.isImplicit()) { limitNode.setProperty(Info.IS_IMPLICIT_LIMIT, true); } if (!limit.isStrict()) { limitNode.setProperty(Info.IS_NON_STRICT, true); } attachLast(limitNode, plan); plan = limitNode; } return plan; }
private static PlanNode attachTupleLimit(PlanNode plan, Limit limit, PlanHints hints) { hints.hasLimit = true; PlanNode limitNode = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT); boolean attach = false; if (limit.getOffset() != null) { limitNode.setProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT, limit.getOffset()); attach = true; } if (limit.getRowLimit() != null) { limitNode.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, limit.getRowLimit()); attach = true; } if (attach) { if (limit.isImplicit()) { limitNode.setProperty(Info.IS_IMPLICIT_LIMIT, true); } if (!limit.isStrict()) { limitNode.setProperty(Info.IS_NON_STRICT, true); } attachLast(limitNode, plan); plan = limitNode; } return plan; }
private static PlanNode attachTupleLimit(PlanNode plan, Limit limit, PlanHints hints) { hints.hasLimit = true; PlanNode limitNode = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT); boolean attach = false; if (limit.getOffset() != null) { limitNode.setProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT, limit.getOffset()); attach = true; } if (limit.getRowLimit() != null) { limitNode.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, limit.getRowLimit()); attach = true; } if (attach) { if (limit.isImplicit()) { limitNode.setProperty(Info.IS_IMPLICIT_LIMIT, true); } if (!limit.isStrict()) { limitNode.setProperty(Info.IS_NON_STRICT, true); } attachLast(limitNode, plan); plan = limitNode; } return plan; }
public boolean planQuery(Collection<GroupSymbol> leftGroups, boolean requireDistinct, PlannedResult plannedResult) throws QueryMetadataException, TeiidComponentException { if ((plannedResult.query.getLimit() != null && !plannedResult.query.getLimit().isImplicit()) || plannedResult.query.getFrom() == null) { return false;
private void processLimit(PlanNode node, QueryCommand query, QueryMetadataInterface metadata) { Expression limit = (Expression)node.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT); Expression offset = (Expression)node.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT); PlanNode limitNode = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT); Expression childLimit = null; Expression childOffset = null; if (query.getLimit() != null) { childLimit = query.getLimit().getRowLimit(); childOffset = query.getLimit().getOffset(); } RulePushLimit.combineLimits(limitNode, metadata, limit, offset, childLimit, childOffset); Limit lim = new Limit((Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT), (Expression)limitNode.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT)); lim.setImplicit(node.hasBooleanProperty(Info.IS_IMPLICIT_LIMIT) && (query.getLimit() == null || query.getLimit().isImplicit())); query.setLimit(lim); }
private void processLimit(PlanNode node, QueryCommand query, QueryMetadataInterface metadata) { Expression limit = (Expression)node.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT); Expression offset = (Expression)node.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT); PlanNode limitNode = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT); Expression childLimit = null; Expression childOffset = null; if (query.getLimit() != null) { childLimit = query.getLimit().getRowLimit(); childOffset = query.getLimit().getOffset(); } RulePushLimit.combineLimits(limitNode, metadata, limit, offset, childLimit, childOffset); Limit lim = new Limit((Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT), (Expression)limitNode.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT)); lim.setImplicit(node.hasBooleanProperty(Info.IS_IMPLICIT_LIMIT) && (query.getLimit() == null || query.getLimit().isImplicit())); query.setLimit(lim); }
private void processLimit(PlanNode node, QueryCommand query, QueryMetadataInterface metadata) { Expression limit = (Expression)node.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT); Expression offset = (Expression)node.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT); PlanNode limitNode = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT); Expression childLimit = null; Expression childOffset = null; if (query.getLimit() != null) { childLimit = query.getLimit().getRowLimit(); childOffset = query.getLimit().getOffset(); } RulePushLimit.combineLimits(limitNode, metadata, limit, offset, childLimit, childOffset); Limit lim = new Limit((Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT), (Expression)limitNode.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT)); lim.setImplicit(node.hasBooleanProperty(Info.IS_IMPLICIT_LIMIT) && (query.getLimit() == null || query.getLimit().isImplicit())); query.setLimit(lim); }
public static void prepareSubquery(SubqueryContainer container) { RelationalPlan subqueryPlan = (RelationalPlan)container.getCommand().getProcessorPlan(); AccessNode aNode = CriteriaCapabilityValidatorVisitor.getAccessNode(subqueryPlan); QueryCommand command = CriteriaCapabilityValidatorVisitor.getQueryCommand(aNode); if (command == null) { return; } final SymbolMap map = container.getCommand().getCorrelatedReferences(); if (map != null) { ExpressionMappingVisitor visitor = new RulePlanSubqueries.ReferenceReplacementVisitor(map); DeepPostOrderNavigator.doVisit(command, visitor); } command.setProcessorPlan(container.getCommand().getProcessorPlan()); boolean removeLimit = false; if (container instanceof ExistsCriteria) { removeLimit = !((ExistsCriteria)container).shouldEvaluate(); } else if (container instanceof ScalarSubquery) { removeLimit = !((ScalarSubquery)container).shouldEvaluate(); } if (removeLimit && command.getLimit() != null && command.getLimit().isImplicit()) { command.setLimit(null); } container.setCommand(command); }
public static void prepareSubquery(SubqueryContainer container) { RelationalPlan subqueryPlan = (RelationalPlan)container.getCommand().getProcessorPlan(); AccessNode aNode = CriteriaCapabilityValidatorVisitor.getAccessNode(subqueryPlan); QueryCommand command = CriteriaCapabilityValidatorVisitor.getQueryCommand(aNode); if (command == null) { return; } final SymbolMap map = container.getCommand().getCorrelatedReferences(); if (map != null) { ExpressionMappingVisitor visitor = new RuleMergeCriteria.ReferenceReplacementVisitor(map); DeepPostOrderNavigator.doVisit(command, visitor); } command.setProcessorPlan(container.getCommand().getProcessorPlan()); boolean removeLimit = false; if (container instanceof ExistsCriteria) { removeLimit = !((ExistsCriteria)container).shouldEvaluate(); } else if (container instanceof ScalarSubquery) { removeLimit = !((ScalarSubquery)container).shouldEvaluate(); } if (removeLimit && command.getLimit() != null && command.getLimit().isImplicit()) { command.setLimit(null); } container.setCommand(command); }
public static void prepareSubquery(SubqueryContainer container) { RelationalPlan subqueryPlan = (RelationalPlan)container.getCommand().getProcessorPlan(); AccessNode aNode = CriteriaCapabilityValidatorVisitor.getAccessNode(subqueryPlan); QueryCommand command = CriteriaCapabilityValidatorVisitor.getQueryCommand(aNode); if (command == null) { return; } final SymbolMap map = container.getCommand().getCorrelatedReferences(); if (map != null) { ExpressionMappingVisitor visitor = new RulePlanSubqueries.ReferenceReplacementVisitor(map); DeepPostOrderNavigator.doVisit(command, visitor); } command.setProcessorPlan(container.getCommand().getProcessorPlan()); boolean removeLimit = false; if (container instanceof ExistsCriteria) { removeLimit = !((ExistsCriteria)container).shouldEvaluate(); } else if (container instanceof ScalarSubquery) { removeLimit = !((ScalarSubquery)container).shouldEvaluate(); } if (removeLimit && command.getLimit() != null && command.getLimit().isImplicit()) { command.setLimit(null); } container.setCommand(command); }
if (command.getLimit() != null && !command.getLimit().isImplicit()) { return null;
if (command.getLimit() != null && !command.getLimit().isImplicit()) { return null;
if (command.getLimit() != null && !command.getLimit().isImplicit()) { return null;