public Query selectQuery() throws TeiidException { if (!this.exceptions.isEmpty()) { throw this.exceptions.get(0); } Query query = this.context.buildQuery(); if (this.countQuery) { AggregateSymbol aggregateSymbol = new AggregateSymbol(AggregateSymbol.Type.COUNT.name(), false, null); Select select = new Select(Arrays.asList(aggregateSymbol)); query.setSelect(select); } else if (this.orderBy != null) { if (this.context.getIterator() != null) { //currently this doesn't matter as the ordering can only be based upon the parent entity ((AggregateSymbol)((AliasSymbol)query.getSelect().getSymbol(query.getSelect().getProjectedSymbols().size() - 1)).getSymbol()).setOrderBy(this.orderBy); } else { query.setOrderBy(this.orderBy); } } if (this.expandOption != null) { processExpandOption(this.expandOption, this.context, query, 1, null); } return query; }
String aggName = t.image.toUpperCase(); AggregateSymbol agg = new AggregateSymbol(aggName, false, expression); agg.setOrderBy(orderBy); {if (true) return agg;} throw new Error("Missing return statement in function");
String aggName = t.image.toUpperCase(); AggregateSymbol agg = new AggregateSymbol(aggName, false, expression); agg.setOrderBy(orderBy); {if (true) return agg;} throw new Error("Missing return statement in function");
String aggName = t.image.toUpperCase(); AggregateSymbol agg = new AggregateSymbol(aggName, false, expression); agg.setOrderBy(orderBy); {if (true) return agg;} throw new Error("Missing return statement in function");
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); }
/** * Return a deep copy of this object */ public Object clone() { AggregateSymbol copy = new AggregateSymbol(getName(), getAggregateFunction(), isDistinct(), LanguageObject.Util.deepClone(getArgs())); if (orderBy != null) { copy.setOrderBy(orderBy.clone()); } if (condition != null) { copy.setCondition((Expression) condition.clone()); } copy.isWindowed = this.isWindowed; copy.type = this.type; copy.setFunctionDescriptor(getFunctionDescriptor()); return copy; }
@Test public void testArrayAggWithOrderBy() throws Exception { String sql = "SELECT array_agg(1 order by e2)"; //$NON-NLS-1$ AggregateSymbol as = new AggregateSymbol(Reserved.ARRAY_AGG, false, new Constant(1)); as.setOrderBy(new OrderBy(Arrays.asList(new ElementSymbol("e2")))); Query query = new Query(); query.setSelect(new Select(Arrays.asList(as))); helpTest(sql, "SELECT ARRAY_AGG(1 ORDER BY e2)", query); }
/** * Return a deep copy of this object */ public Object clone() { AggregateSymbol copy = new AggregateSymbol(getName(), getAggregateFunction(), isDistinct(), LanguageObject.Util.deepClone(getArgs())); if (orderBy != null) { copy.setOrderBy(orderBy.clone()); } if (condition != null) { copy.setCondition((Expression) condition.clone()); } copy.isWindowed = this.isWindowed; copy.type = this.type; copy.setFunctionDescriptor(getFunctionDescriptor()); return copy; }
/** * Return a deep copy of this object */ public Object clone() { AggregateSymbol copy = new AggregateSymbol(getName(), getAggregateFunction(), isDistinct(), LanguageObject.Util.deepClone(getArgs())); if (orderBy != null) { copy.setOrderBy(orderBy.clone()); } if (condition != null) { copy.setCondition((Expression) condition.clone()); } copy.isWindowed = this.isWindowed; copy.type = this.type; copy.setFunctionDescriptor(getFunctionDescriptor()); return copy; }
@Test public void testTextAggWithOrderBy() throws Exception { List<DerivedColumn> expressions = new ArrayList<DerivedColumn>(); expressions.add(new DerivedColumn("col1", new ElementSymbol("e1"))); expressions.add(new DerivedColumn("col2", new ElementSymbol("e2"))); TextLine tf = new TextLine(); tf.setExpressions(expressions); tf.setDelimiter(new Character(',')); tf.setIncludeHeader(true); AggregateSymbol as = new AggregateSymbol(NonReserved.TEXTAGG, false, tf); as.setOrderBy(new OrderBy(Arrays.asList(new ElementSymbol("e2")))); Query query = new Query(); query.setSelect(new Select(Arrays.asList(as))); String sql = "SELECT TextAgg(FOR e1 as col1, e2 as col2 delimiter ',' header order by e2)"; //$NON-NLS-1$ helpTest(sql, "SELECT TEXTAGG(FOR e1 AS col1, e2 AS col2 DELIMITER ',' HEADER ORDER BY e2)", query); }
@Test public void testXmlAggWithOrderBy() throws Exception { String sql = "SELECT xmlAgg(1 order by e2)"; //$NON-NLS-1$ AggregateSymbol as = new AggregateSymbol(Reserved.XMLAGG, false, new Constant(1)); as.setOrderBy(new OrderBy(Arrays.asList(new ElementSymbol("e2")))); Query query = new Query(); query.setSelect(new Select(Arrays.asList(as))); helpTest(sql, "SELECT XMLAGG(1 ORDER BY e2)", query); }
tf.setEncoding(encoding); AggregateSymbol agg = new AggregateSymbol("TEXTAGG", false, tf); agg.setOrderBy(orderBy); {if (true) return agg;} throw new Error("Missing return statement in function");
tf.setEncoding(encoding); AggregateSymbol agg = new AggregateSymbol("TEXTAGG", false, tf); agg.setOrderBy(orderBy); {if (true) return agg;} throw new Error("Missing return statement in function");
tf.setEncoding(encoding); AggregateSymbol agg = new AggregateSymbol("TEXTAGG", false, tf); agg.setOrderBy(orderBy); {if (true) return agg;} throw new Error("Missing return statement in function");