private void validateSubquery(SubqueryContainer<?> subQuery) { if (subQuery.getCommand() instanceof Query && ((Query)subQuery.getCommand()).getInto() != null) { handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.subquery_insert"), subQuery.getCommand()); //$NON-NLS-1$ } }
/** * @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 validateSubquery(SubqueryContainer<?> subQuery) { if (subQuery.getCommand() instanceof Query && ((Query)subQuery.getCommand()).getInto() != null) { handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.subquery_insert"), subQuery.getCommand()); //$NON-NLS-1$ } }
/** * @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 validateSubquery(SubqueryContainer<?> subQuery) { if (subQuery.getCommand() instanceof Query && ((Query)subQuery.getCommand()).getInto() != null) { handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.subquery_insert"), subQuery.getCommand()); //$NON-NLS-1$ } }
/** * @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)); } }
public List<SymbolMap> getCorrelatedReferences() { List<SubqueryContainer<?>> containers = getSubqueryContainers(); if (containers.isEmpty()) { return Collections.emptyList(); } ArrayList<SymbolMap> result = new ArrayList<SymbolMap>(containers.size()); for (SubqueryContainer<?> container : containers) { SymbolMap map = container.getCommand().getCorrelatedReferences(); if (map != null) { result.add(map); } } return result; }
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 List<SymbolMap> getCorrelatedReferences() { List<SubqueryContainer<?>> containers = getSubqueryContainers(); if (containers.isEmpty()) { return Collections.emptyList(); } ArrayList<SymbolMap> result = new ArrayList<SymbolMap>(containers.size()); for (SubqueryContainer<?> container : containers) { SymbolMap map = container.getCommand().getCorrelatedReferences(); if (map != null) { result.add(map); } } return result; }
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 List<SymbolMap> getCorrelatedReferences() { List<SubqueryContainer<?>> containers = getSubqueryContainers(); if (containers.isEmpty()) { return Collections.emptyList(); } ArrayList<SymbolMap> result = new ArrayList<SymbolMap>(containers.size()); for (SubqueryContainer<?> container : containers) { SymbolMap map = container.getCommand().getCorrelatedReferences(); if (map != null) { result.add(map); } } return result; }
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 resolveSubqueries(Command command, TempMetadataAdapter metadata, Collection<GroupSymbol> externalGroups) throws QueryResolverException, TeiidComponentException { for (SubqueryContainer<?> container : ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(command)) { QueryResolver.setChildMetadata(container.getCommand(), command); if (externalGroups != null) { container.getCommand().pushNewResolvingContext(externalGroups); } QueryResolver.resolveCommand(container.getCommand(), metadata.getMetadata(), false); } }
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 resolveSubqueries(Command command, TempMetadataAdapter metadata, Collection<GroupSymbol> externalGroups) throws QueryResolverException, TeiidComponentException { for (SubqueryContainer<?> container : ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(command)) { QueryResolver.setChildMetadata(container.getCommand(), command); if (externalGroups != null) { container.getCommand().pushNewResolvingContext(externalGroups); } QueryResolver.resolveCommand(container.getCommand(), metadata.getMetadata(), false); } }
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 resolveSubqueries(Command command, TempMetadataAdapter metadata, Collection<GroupSymbol> externalGroups) throws QueryResolverException, TeiidComponentException { for (SubqueryContainer container : ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(command)) { QueryResolver.setChildMetadata(container.getCommand(), command); if (externalGroups != null) { container.getCommand().pushNewResolvingContext(externalGroups); } QueryResolver.resolveCommand(container.getCommand(), metadata.getMetadata(), false); } }
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 Boolean requiresTransaction(boolean transactionalReads, List<SubqueryContainer<?>> valueIteratorProviders) { for (SubqueryContainer<?> subquery : valueIteratorProviders) { ProcessorPlan plan = subquery.getCommand().getProcessorPlan(); if (plan != null) { Boolean txn = plan.requiresTransaction(transactionalReads); if (txn == null || txn) { return true; //we can't ensure that this is read only } } } return false; }
public static Boolean requiresTransaction(boolean transactionalReads, List<SubqueryContainer<?>> valueIteratorProviders) { for (SubqueryContainer<?> subquery : valueIteratorProviders) { ProcessorPlan plan = subquery.getCommand().getProcessorPlan(); if (plan != null) { Boolean txn = plan.requiresTransaction(transactionalReads); if (txn == null || txn) { return true; //we can't ensure that this is read only } } } return false; }