/** * @param removeOrderBy * @param assStmt * @throws QueryValidatorException */ private void rewriteSubqueryContainer(SubqueryContainer container, boolean removeOrderBy) throws TeiidComponentException, TeiidProcessingException{ if (rewriteSubcommands && container.getCommand() != null && (container.getCommand().getProcessorPlan() == null || processing)) { container.setCommand(rewriteCommand(container.getCommand(), removeOrderBy)); } }
/** * @param removeOrderBy * @param assStmt * @throws QueryValidatorException */ private void rewriteSubqueryContainer(SubqueryContainer container, boolean removeOrderBy) throws TeiidComponentException, TeiidProcessingException{ if (rewriteSubcommands && container.getCommand() != null && (container.getCommand().getProcessorPlan() == null || processing)) { container.setCommand(rewriteCommand(container.getCommand(), removeOrderBy)); } }
/** * @param removeOrderBy * @param assStmt * @throws QueryValidatorException */ private void rewriteSubqueryContainer(SubqueryContainer container, boolean removeOrderBy) throws TeiidComponentException, TeiidProcessingException{ if (rewriteSubcommands && container.getCommand() != null && (container.getCommand().getProcessorPlan() == null || processing)) { container.setCommand(rewriteCommand(container.getCommand(), removeOrderBy)); } }
private void rewriteWithExplicitArray(Expression ex, SubqueryContainer<QueryCommand> sub) throws QueryMetadataException, QueryResolverException, TeiidComponentException { if (!(ex instanceof Array) || sub.getCommand() == null || sub.getCommand().getProjectedSymbols().size() == 1) { return; } Query query = QueryRewriter.createInlineViewQuery(new GroupSymbol("x"), sub.getCommand(), metadata, sub.getCommand().getProjectedSymbols()); //$NON-NLS-1$ List<Expression> exprs = new ArrayList<Expression>(); for (Expression expr : query.getSelect().getProjectedSymbols()) { exprs.add(SymbolMap.getExpression(expr)); } Array array = new Array(exprs); query.getSelect().clearSymbols(); query.getSelect().addSymbol(array); ResolverVisitor.resolveComponentType(array); sub.setCommand(query); }
private void rewriteWithExplicitArray(Expression ex, SubqueryContainer<QueryCommand> sub) throws QueryMetadataException, QueryResolverException, TeiidComponentException { if (!(ex instanceof Array) || sub.getCommand() == null || sub.getCommand().getProjectedSymbols().size() == 1) { return; } Query query = QueryRewriter.createInlineViewQuery(new GroupSymbol("x"), sub.getCommand(), metadata, sub.getCommand().getProjectedSymbols()); //$NON-NLS-1$ List<Expression> exprs = new ArrayList<Expression>(); for (Expression expr : query.getSelect().getProjectedSymbols()) { exprs.add(SymbolMap.getExpression(expr)); } Array array = new Array(exprs); query.getSelect().clearSymbols(); query.getSelect().addSymbol(array); ResolverVisitor.resolveComponentType(array); sub.setCommand(query); }
private void rewriteWithExplicitArray(Expression ex, SubqueryContainer<QueryCommand> sub) throws QueryMetadataException, QueryResolverException, TeiidComponentException { if (!(ex instanceof Array) || sub.getCommand() == null || sub.getCommand().getProjectedSymbols().size() == 1) { return; } Query query = QueryRewriter.createInlineViewQuery(new GroupSymbol("x"), sub.getCommand(), metadata, sub.getCommand().getProjectedSymbols()); //$NON-NLS-1$ List<Expression> exprs = new ArrayList<Expression>(); for (Expression expr : query.getSelect().getProjectedSymbols()) { exprs.add(SymbolMap.getExpression(expr)); } Array array = new Array(exprs); query.getSelect().clearSymbols(); query.getSelect().addSymbol(array); ResolverVisitor.resolveComponentType(array); sub.setCommand(query); }
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); }
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); }