public AssignmentStatement(ElementSymbol variable, QueryCommand value) { this.variable = variable; this.value = new ScalarSubquery(value); }
/** * Returns a safe clone * @see java.lang.Object#clone() */ public Object clone() { QueryCommand copyCommand = null; if(getCommand() != null) { copyCommand = (QueryCommand) getCommand().clone(); } ScalarSubquery clone = new ScalarSubquery(copyCommand); //Don't invoke the lazy-loading getType() clone.setType(this.type); clone.shouldEvaluate = this.shouldEvaluate; if (this.subqueryHint != null) { clone.subqueryHint = subqueryHint.clone(); } return clone; }
public void visit(ScalarSubquery obj) { if (obj.getType() == null){ this.unresolvedSymbols.add(obj); } }
private void markEvaluatable(ScalarSubquery obj, boolean canPreEval, String reasonWhyInvalid) { if (canPreEval) { obj.setShouldEvaluate(true); } else { markInvalid(obj.getCommand(), reasonWhyInvalid); } }
public PlannedResult findSubquery(Expression expr, boolean unnest, PlannedResult result, boolean requireSingleRow) throws QueryMetadataException, TeiidComponentException { if (expr instanceof ScalarSubquery) { ScalarSubquery scc = (ScalarSubquery)expr; if (scc.getSubqueryHint().isNoUnnest()) { return result; } Query query = (Query)scc.getCommand(); result.multiRow = !isSingleRow(query); result.type = scc.getClass(); result.mergeJoin = scc.getSubqueryHint().isMergeJoin(); if (!unnest && !result.mergeJoin) { return result; } result.makeInd = scc.getSubqueryHint().isDepJoin(); result.query = query; } return result; }
private void buildAggregateQuery(DocumentNode node, Query outerQuery, ExpandDocumentNode expandResource, OrderBy expandOrder, Query query, EdmNavigationProperty navigationProperty) throws TeiidException { Select select = query.getSelect(); Array array = new Array(Object.class, new ArrayList<Expression>(select.getSymbols())); select.getSymbols().clear(); AggregateSymbol symbol = new AggregateSymbol(AggregateSymbol.Type.ARRAY_AGG.name(), false, array); select.addSymbol(symbol); symbol.setOrderBy(expandOrder); Criteria crit = node.buildJoinCriteria(expandResource, navigationProperty); if (crit != null) { query.setCriteria(Criteria.combineCriteria(crit, query.getCriteria())); } // else assertion error? expandResource.setColumnIndex(outerQuery.getSelect().getCount() + 1); ScalarSubquery agg = new ScalarSubquery(query); SubqueryHint subqueryHint = new SubqueryHint(); subqueryHint.setMergeJoin(true); agg.setSubqueryHint(subqueryHint); outerQuery.getSelect().addSymbol(agg); }
} else if (expression instanceof ScalarSubquery) { ScalarSubquery subquery = (ScalarSubquery)expression; if (subquery.shouldEvaluate() && processing) { return new Constant(evaluator.evaluate(subquery, null), subquery.getType()); if (!RelationalNodeUtil.shouldExecute(subquery.getCommand(), false, true)) { return new Constant(null, subquery.getType()); if (subquery.getCommand().getProcessorPlan() == null) { addImplicitLimit(subquery, 2);
public void visit(ScalarSubquery obj) { this.commands.add(obj.getCommand()); }
public void visit(ScalarSubquery obj) { if (obj.shouldEvaluate()) { return; } visitor.createChildNamingContext(false); visitNode(obj.getCommand()); visitor.removeChildNamingContext(); }
@Override public void visit(ScalarSubquery obj) { try { if (obj.shouldEvaluate()) { return; boolean canPreEval = obj.getCommand().getCorrelatedReferences() == null; if(!this.caps.supportsCapability(Capability.QUERY_SUBQUERIES_SCALAR)) { markEvaluatable(obj, canPreEval, "Correlated/nonDeterministic ScalarSubquery is not supported"); //$NON-NLS-1$ } else if (canPreEval) { Collection<GroupSymbol> groups = GroupCollectorVisitor.getGroupsIgnoreInlineViews(obj.getCommand(), true); boolean allTemp = true; for (GroupSymbol gs : groups) { obj.setShouldEvaluate(true);
f.setFunctionDescriptor(fd); select.addSymbol(f); ss = new ScalarSubquery(command); SymbolMap correlatedReferences = new SymbolMap(); Collection<ElementSymbol> elements = ElementCollectorVisitor.getElements(function, true); ((Function)((ExpressionSymbol)ss.getCommand().getProjectedSymbols().get(0)).getExpression()).setArgs(functionArgs);
public static org.teiid.query.sql.symbol.ScalarSubquery helpExample() { Query query = TestQueryImpl.helpExample(true); org.teiid.query.sql.symbol.ScalarSubquery ss = new org.teiid.query.sql.symbol.ScalarSubquery(query); ss.setType(((Expression)query.getProjectedSymbols().get(0)).getType()); return ss; }
public void visit(ScalarSubquery obj){ if (obj.shouldEvaluate()) { evaluationNotPossible(EvaluationLevel.PROCESSING); } else { evaluationNotPossible(EvaluationLevel.PUSH_DOWN); } }
public static void setTypeIfNull(Expression symbol, Class<?> replacement) { if(!DataTypeManager.DefaultDataClasses.NULL.equals(symbol.getType()) && symbol.getType() != null) { return; } symbol = SymbolMap.getExpression(symbol); if(symbol instanceof Constant) { ((Constant)symbol).setType(replacement); } else if (symbol instanceof AbstractCaseExpression) { ((AbstractCaseExpression)symbol).setType(replacement); } else if (symbol instanceof ScalarSubquery) { ((ScalarSubquery)symbol).setType(replacement); } else if(symbol instanceof ElementSymbol) { ElementSymbol elementSymbol = (ElementSymbol)symbol; elementSymbol.setType(replacement); } else { try { ResolverUtil.setDesiredType(symbol, replacement, symbol); } catch (QueryResolverException e) { //cannot happen } } }
public ScalarSubquery(QueryCommand subqueryCommand){ this.setCommand(subqueryCommand); }
if (subqueryContainer.getCommand().getCorrelatedReferences() == null) { if (subqueryContainer instanceof ScalarSubquery) { ((ScalarSubquery) subqueryContainer).setShouldEvaluate(true); } else if (subqueryContainer instanceof ExistsCriteria) { ((ExistsCriteria) subqueryContainer).setShouldEvaluate(true);
@Test public void testScalarSubqueryWithHint() { Select s1 = new Select(); s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$ From f1 = new From(); f1.addGroup(new GroupSymbol("m.g1")); //$NON-NLS-1$ Query q1 = new Query(); q1.setSelect(s1); q1.setFrom(f1); ScalarSubquery obj = new ScalarSubquery(q1); SubqueryHint subqueryHint = new SubqueryHint(); subqueryHint.setMergeJoin(true); obj.setSubqueryHint(subqueryHint); helpTest(obj, " /*+ MJ */ (SELECT e1 FROM m.g1)"); //$NON-NLS-1$ }
public PlannedResult findSubquery(Expression expr, boolean unnest, PlannedResult result, boolean requireSingleRow) throws QueryMetadataException, TeiidComponentException { if (expr instanceof ScalarSubquery) { ScalarSubquery scc = (ScalarSubquery)expr; if (scc.getSubqueryHint().isNoUnnest()) { return result; } Query query = (Query)scc.getCommand(); result.multiRow = !isSingleRow(query); result.type = scc.getClass(); result.mergeJoin = scc.getSubqueryHint().isMergeJoin(); if (!unnest && !result.mergeJoin) { return result; } result.makeInd = scc.getSubqueryHint().isDepJoin(); result.query = query; } return result; }
} else if (expression instanceof ScalarSubquery) { ScalarSubquery subquery = (ScalarSubquery)expression; if (subquery.shouldEvaluate() && processing) { return new Constant(evaluator.evaluate(subquery, null), subquery.getType()); if (!RelationalNodeUtil.shouldExecute(subquery.getCommand(), false, true)) { return new Constant(null, subquery.getType()); if (subquery.getCommand().getProcessorPlan() == null) { addImplicitLimit(subquery, 2);
public void visit(ScalarSubquery obj) { this.commands.add(obj.getCommand()); }