mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 12:07:42 +00:00
(improvement)(chat) fix count_distinct error in struct query and not init S2SqlByStruct if isUseS2SqlSwitch is false (#353)
This commit is contained in:
@@ -38,6 +38,7 @@ public class QueryParser {
|
||||
if (semanticConverter.accept(queryStructReq)) {
|
||||
log.info("SemanticConverter accept [{}]", semanticConverter.getClass().getName());
|
||||
semanticConverter.converter(catalog, queryStructReq, parseSqlReq, metricReq);
|
||||
log.info("SemanticConverter accept [{}]", semanticConverter.getClass().getName());
|
||||
}
|
||||
}
|
||||
log.info("SemanticConverter after {} {} {}", queryStructReq, metricReq, parseSqlReq);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.tencent.supersonic.semantic.query.utils;
|
||||
import static com.tencent.supersonic.common.pojo.Constants.JOIN_UNDERLINE;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.Aggregator;
|
||||
import com.tencent.supersonic.common.pojo.enums.AggOperatorEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.TimeDimensionEnum;
|
||||
import com.tencent.supersonic.semantic.api.query.request.QueryStructReq;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -54,6 +55,9 @@ public class SqlGenerateUtils {
|
||||
}
|
||||
|
||||
public String getSelectField(final Aggregator agg) {
|
||||
if (AggOperatorEnum.COUNT_DISTINCT.equals(agg.getFunc())) {
|
||||
return "count(distinct " + agg.getColumn() + " ) AS " + agg.getColumn() + " ";
|
||||
}
|
||||
if (CollectionUtils.isEmpty(agg.getArgs())) {
|
||||
return agg.getFunc() + "( " + agg.getColumn() + " ) AS " + agg.getColumn() + " ";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user