mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 04:27:39 +00:00
(improvement)(Headless) Change queryMode TAG_MODE to DETAIL_MODE (#1050)
This commit is contained in:
@@ -94,7 +94,7 @@ public class ParseInfoProcessor implements ResultProcessor {
|
||||
List<String> groupByFields = SqlSelectHelper.getGroupByFields(sqlInfo.getCorrectS2SQL());
|
||||
List<String> groupByDimensions = getFieldsExceptDate(groupByFields);
|
||||
parseInfo.setDimensions(getElements(dataSetId, groupByDimensions, semanticSchema.getDimensions()));
|
||||
} else if (QueryType.TAG.equals(parseInfo.getQueryType())) {
|
||||
} else if (QueryType.DETAIL.equals(parseInfo.getQueryType())) {
|
||||
List<String> selectFields = SqlSelectHelper.getSelectFields(sqlInfo.getCorrectS2SQL());
|
||||
List<String> selectDimensions = getFieldsExceptDate(selectFields);
|
||||
parseInfo.setDimensions(getElements(dataSetId, selectDimensions, semanticSchema.getDimensions()));
|
||||
|
||||
@@ -600,7 +600,7 @@ public class ChatQueryServiceImpl implements ChatQueryService {
|
||||
sqlInfo.setCorrectS2SQL(querySqlReq.getSql());
|
||||
sqlInfo.setS2SQL(querySqlReq.getSql());
|
||||
semanticParseInfo.setSqlInfo(sqlInfo);
|
||||
semanticParseInfo.setQueryType(QueryType.TAG);
|
||||
semanticParseInfo.setQueryType(QueryType.DETAIL);
|
||||
|
||||
Long dataSetId = querySqlReq.getDataSetId();
|
||||
if (Objects.isNull(dataSetId)) {
|
||||
|
||||
@@ -223,7 +223,8 @@ public class DataSetServiceImpl
|
||||
queryReq = new QuerySqlReq();
|
||||
}
|
||||
BeanUtils.copyProperties(queryDataSetReq, queryReq);
|
||||
if (Objects.nonNull(queryDataSetReq.getQueryType()) && QueryType.TAG.equals(queryDataSetReq.getQueryType())) {
|
||||
if (Objects.nonNull(queryDataSetReq.getQueryType())
|
||||
&& QueryType.DETAIL.equals(queryDataSetReq.getQueryType())) {
|
||||
queryReq.setInnerLayerNative(true);
|
||||
}
|
||||
return queryReq;
|
||||
|
||||
@@ -151,7 +151,7 @@ public class SemanticService {
|
||||
DataSetSchema dataSetSchema, User user) {
|
||||
SemanticParseInfo semanticParseInfo = new SemanticParseInfo();
|
||||
semanticParseInfo.setDataSet(dataSetSchema.getDataSet());
|
||||
semanticParseInfo.setQueryType(QueryType.TAG);
|
||||
semanticParseInfo.setQueryType(QueryType.DETAIL);
|
||||
semanticParseInfo.setMetrics(getMetrics(entityInfo));
|
||||
semanticParseInfo.setDimensions(getDimensions(entityInfo));
|
||||
DateConf dateInfo = new DateConf();
|
||||
|
||||
@@ -28,6 +28,15 @@ import com.tencent.supersonic.headless.core.adaptor.db.DbAdaptorFactory;
|
||||
import com.tencent.supersonic.headless.core.pojo.DataSetQueryParam;
|
||||
import com.tencent.supersonic.headless.core.pojo.QueryStatement;
|
||||
import com.tencent.supersonic.headless.core.utils.SqlGenerateUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -37,14 +46,6 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@@ -242,7 +243,7 @@ public class QueryReqConverter {
|
||||
|
||||
private QueryType getQueryType(AggOption aggOption) {
|
||||
boolean isAgg = AggOption.isAgg(aggOption);
|
||||
QueryType queryType = QueryType.TAG;
|
||||
QueryType queryType = QueryType.DETAIL;
|
||||
if (isAgg) {
|
||||
queryType = QueryType.METRIC;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class QueryReqBuilderTest {
|
||||
+ "WHERE (sys_imp_date IN ('2023-08-01')) GROUP "
|
||||
+ "BY department ORDER BY uv LIMIT 2000", querySQLReq.getSql());
|
||||
|
||||
queryStructReq.setQueryType(QueryType.TAG);
|
||||
queryStructReq.setQueryType(QueryType.DETAIL);
|
||||
querySQLReq = queryStructReq.convert();
|
||||
Assert.assertEquals(
|
||||
"SELECT department, pv FROM 内容库 WHERE (sys_imp_date IN ('2023-08-01')) "
|
||||
|
||||
Reference in New Issue
Block a user