1 Commits

Author SHA1 Message Date
mislayming
943ae56301 Merge aaf2d46a56 into 94e853f57e 2025-02-21 12:06:21 +08:00

View File

@@ -86,17 +86,17 @@ public class SqlGenerateUtils {
public String getSelectField(final Aggregator agg) {
if (AggOperatorEnum.COUNT_DISTINCT.equals(agg.getFunc())) {
return "count(distinct " + agg.getColumn() + " ) ";
return "count(distinct " + agg.getColumn() + " ) AS " + agg.getColumn() + " ";
}
if (CollectionUtils.isEmpty(agg.getArgs())) {
return agg.getFunc() + "( " + agg.getColumn() + " ) ";
return agg.getFunc() + "( " + agg.getColumn() + " ) AS " + agg.getColumn() + " ";
}
return agg.getFunc() + "( "
+ agg.getArgs().stream()
.map(arg -> arg.equals(agg.getColumn()) ? arg
: (StringUtils.isNumeric(arg) ? arg : ("'" + arg + "'")))
.collect(Collectors.joining(","))
+ " ) ";
+ " ) AS " + agg.getColumn() + " ";
}
public String getSelectField(final Aggregator agg, Map<String, String> deriveMetrics) {