@Override public Class<?> getType() { return function.getType(); }
public Class<?> getOutputType(AggregateSymbol function) { return function.getType(); }
public Class<?> getOutputType(AggregateSymbol function) { return function.getType(); }
@Override public Class<?> getType() { return function.getType(); }
@Override public Class<?> getType() { return function.getType(); }
AggregateFunction translate(AggregateSymbol symbol) { List<org.teiid.language.Expression> params = new ArrayList<org.teiid.language.Expression>(symbol.getArgs().length); for (Expression expression : symbol.getArgs()) { params.add(translate(expression)); } String name = symbol.getAggregateFunction().name(); if (symbol.getAggregateFunction() == AggregateSymbol.Type.USER_DEFINED) { name = symbol.getName(); } AggregateFunction af = new AggregateFunction(name, symbol.isDistinct(), params, symbol.getType()); af.setCondition(translate(symbol.getCondition())); af.setOrderBy(translate(symbol.getOrderBy(), false)); return af; }
if (agg.isCount()) { if (isCountStar(agg)) { allSymbols.addSymbol(new ExpressionSymbol("stagedAgg", newLiteral(1, agg.getType()))); //$NON-NLS-1$ } else { SearchedCaseExpression count = new SearchedCaseExpression(Arrays.asList(new IsNullCriteria(agg.getArg(0))), Arrays.asList(newLiteral(0, agg.getType()))); count.setElseExpression(newLiteral(1, agg.getType())); count.setType(agg.getType()); allSymbols.addSymbol(new ExpressionSymbol("stagedAgg", count)); //$NON-NLS-1$ assert agg.getArgs().length == 1; //prior canStage should ensure this is true Expression ex = agg.getArg(0); ex = ResolverUtil.convertExpression(ex, DataTypeManager.getDataTypeName(agg.getType()), metadata); allSymbols.addSymbol(new ExpressionSymbol("stagedAgg", ex)); //$NON-NLS-1$
if (agg.isCount()) { if (isCountStar(agg)) { allSymbols.addSymbol(new ExpressionSymbol("stagedAgg", newLiteral(1, agg.getType()))); //$NON-NLS-1$ } else { SearchedCaseExpression count = new SearchedCaseExpression(Arrays.asList(new IsNullCriteria(agg.getArg(0))), Arrays.asList(newLiteral(0, agg.getType()))); count.setElseExpression(newLiteral(1, agg.getType())); count.setType(agg.getType()); allSymbols.addSymbol(new ExpressionSymbol("stagedAgg", count)); //$NON-NLS-1$ assert agg.getArgs().length == 1; //prior canStage should ensure this is true Expression ex = agg.getArg(0); ex = ResolverUtil.convertExpression(ex, DataTypeManager.getDataTypeName(agg.getType()), metadata); allSymbols.addSymbol(new ExpressionSymbol("stagedAgg", ex)); //$NON-NLS-1$
break; case STRING_AGG: result = new StringAgg(aggSymbol.getType() == DataTypeManager.DefaultDataClasses.BLOB); break; case FIRST_VALUE: result = new FirstLastValue(aggSymbol.getType(), true); break; case LAST_VALUE: result = new FirstLastValue(aggSymbol.getType(), false); break; case LEAD: result.setConditionIndex(getIndex(aggSymbol.getCondition(), expressionIndexes)); result.initialize(aggSymbol.getType(), inputTypes); return result;
Expression intSum = ResolverUtil.getConversion(sumCount, DataTypeManager.getDataTypeName(sumCount.getType()), DataTypeManager.DefaultDataTypes.INTEGER, false, metadata.getFunctionLibrary());
assert agg.getArgs().length == 1; //prior canStage should ensure this is true Expression ex = agg.getArg(0); ex = ResolverUtil.convertExpression(ex, DataTypeManager.getDataTypeName(agg.getType()), metadata); allSymbols.addSymbol(new ExpressionSymbol("stagedAgg", ex)); //$NON-NLS-1$
Expression intSum = ResolverUtil.getConversion(sumCount, DataTypeManager.getDataTypeName(sumCount.getType()), DataTypeManager.DefaultDataTypes.INTEGER, false, metadata.getFunctionLibrary());
Expression intSum = ResolverUtil.getConversion(sumCount, DataTypeManager.getDataTypeName(sumCount.getType()), DataTypeManager.DefaultDataTypes.INTEGER, false, metadata.getFunctionLibrary());
AggregateFunction translate(AggregateSymbol symbol) { List<org.teiid.language.Expression> params = new ArrayList<org.teiid.language.Expression>(symbol.getArgs().length); for (Expression expression : symbol.getArgs()) { params.add(translate(expression)); } String name = symbol.getAggregateFunction().name(); if (symbol.getFunctionDescriptor() != null) { name = Symbol.getShortName(symbol.getFunctionDescriptor().getName()); } else if (symbol.getAggregateFunction() == AggregateSymbol.Type.USER_DEFINED) { name = symbol.getName(); } else if (symbol.getAggregateFunction() == Type.COUNT_BIG && !supportsCountBig) { name = Type.COUNT.name(); } AggregateFunction af = new AggregateFunction(name, symbol.isDistinct(), params, symbol.getType()); af.setCondition(translate(symbol.getCondition())); af.setOrderBy(translate(symbol.getOrderBy(), false)); if (symbol.getFunctionDescriptor() != null) { af.setMetadataObject(symbol.getFunctionDescriptor().getMethod()); } return af; }
AggregateFunction translate(AggregateSymbol symbol) { List<org.teiid.language.Expression> params = new ArrayList<org.teiid.language.Expression>(symbol.getArgs().length); for (Expression expression : symbol.getArgs()) { params.add(translate(expression)); } String name = symbol.getAggregateFunction().name(); if (symbol.getFunctionDescriptor() != null) { name = Symbol.getShortName(symbol.getFunctionDescriptor().getName()); } else if (symbol.getAggregateFunction() == AggregateSymbol.Type.USER_DEFINED) { name = symbol.getName(); } else if (symbol.getAggregateFunction() == Type.COUNT_BIG && !supportsCountBig) { name = Type.COUNT.name(); } AggregateFunction af = new AggregateFunction(name, symbol.isDistinct(), params, symbol.getType()); af.setCondition(translate(symbol.getCondition())); af.setOrderBy(translate(symbol.getOrderBy(), false)); if (symbol.getFunctionDescriptor() != null) { af.setMetadataObject(symbol.getFunctionDescriptor().getMethod()); } return af; }
Function func = new Function(FunctionLibrary.CONVERT, new Expression[] {newAgg, new Constant(DataTypeManager.getDataTypeName(partitionAgg.getType()))}); if (join) { func = new Function(FunctionLibrary.IFNULL, new Expression[] {func, new Constant(0, DataTypeManager.DefaultDataClasses.INTEGER)}); AggregateSymbol sumCountAgg = new AggregateSymbol(NonReserved.SUM, false, countAgg); Expression convertedSum = new Function(FunctionLibrary.CONVERT, new Expression[] {sumSumAgg, new Constant(DataTypeManager.getDataTypeName(partitionAgg.getType()))}); Expression convertCount = new Function(FunctionLibrary.CONVERT, new Expression[] {sumCountAgg, new Constant(DataTypeManager.getDataTypeName(partitionAgg.getType()))});
if((aggregateFunction == Type.SUM || aggregateFunction == Type.AVG) && obj.getType() == null) { handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0041", new Object[] {aggregateFunction, obj}), obj); //$NON-NLS-1$ } else if (obj.getType() != DataTypeManager.DefaultDataClasses.NULL) { if (aggregateFunction == Type.XMLAGG && aggExps[0].getType() != DataTypeManager.DefaultDataClasses.XML) { handleValidationError(QueryPlugin.Util.getString("AggregateValidationVisitor.non_xml", new Object[] {aggregateFunction, obj}), obj); //$NON-NLS-1$ } else if (aggregateFunction == Type.JSONARRAY_AGG) { validateJSONValue(obj, aggExps[0]); } else if (obj.getType() == null && obj.getArgs().length > 0) { handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.aggregate_type", obj), obj); //$NON-NLS-1$
if((aggregateFunction == Type.SUM || aggregateFunction == Type.AVG) && obj.getType() == null) { handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0041", new Object[] {aggregateFunction, obj}), obj); //$NON-NLS-1$ } else if (obj.getType() != DataTypeManager.DefaultDataClasses.NULL) { if (aggregateFunction == Type.XMLAGG && aggExps[0].getType() != DataTypeManager.DefaultDataClasses.XML) { handleValidationError(QueryPlugin.Util.getString("AggregateValidationVisitor.non_xml", new Object[] {aggregateFunction, obj}), obj); //$NON-NLS-1$ } else if (aggregateFunction == Type.JSONARRAY_AGG) { validateJSONValue(obj, aggExps[0]); } else if (obj.getType() == null && obj.getArgs().length > 0) { handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.aggregate_type", obj), obj); //$NON-NLS-1$
throw new QueryResolverException(QueryPlugin.Event.TEIID31140, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31140, obj)); if (obj.getType() == null) { Expression arg = obj.getArg(0); Expression arg1 = obj.getArg(1);
throw new QueryResolverException(QueryPlugin.Event.TEIID31140, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31140, obj)); if (obj.getType() == null) { Expression arg = obj.getArg(0); Expression arg1 = obj.getArg(1);