mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-13 13:07:32 +00:00
(improvement)(headless) add checkTag when query tagValue and opt tag convert (#814)
This commit is contained in:
@@ -240,7 +240,6 @@ public class TagMetaServiceImpl implements TagMetaService {
|
||||
num += loadDimTagBatch(tagLoadReq, dimensions, user);
|
||||
}
|
||||
if (Objects.isNull(tagLoadReq.getType()) || SchemaElementType.METRIC.equals(tagLoadReq.getType())) {
|
||||
|
||||
List<MetricResp> metrics = metricService.getMetrics(metaFilter);
|
||||
num += loadMetricTagBatch(tagLoadReq, metrics, user);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.tencent.supersonic.common.pojo.enums.AggOperatorEnum;
|
||||
import com.tencent.supersonic.headless.api.pojo.Dim;
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaElementType;
|
||||
import com.tencent.supersonic.headless.api.pojo.ValueDistribution;
|
||||
import com.tencent.supersonic.headless.api.pojo.enums.TagDefineType;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.ItemValueReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.QuerySqlReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.QueryTagReq;
|
||||
@@ -62,6 +63,7 @@ public class TagQueryServiceImpl implements TagQueryService {
|
||||
itemValueResp.setItemId(itemValueReq.getItemId());
|
||||
itemValueResp.setType(SchemaElementType.TAG);
|
||||
TagResp tag = tagMetaService.getTag(itemValueReq.getItemId(), user);
|
||||
checkTag(tag);
|
||||
itemValueResp.setName(tag.getName());
|
||||
itemValueResp.setBizName(tag.getBizName());
|
||||
correctDateConf(itemValueReq, tag, user);
|
||||
@@ -74,6 +76,12 @@ public class TagQueryServiceImpl implements TagQueryService {
|
||||
return itemValueResp;
|
||||
}
|
||||
|
||||
private void checkTag(TagResp tag) throws Exception {
|
||||
if (Objects.nonNull(tag) && TagDefineType.METRIC.equals(tag.getTagDefineType())) {
|
||||
throw new Exception("do not support value distribution query for tag: " + tag.getBizName());
|
||||
}
|
||||
}
|
||||
|
||||
private void correctDateConf(ItemValueReq itemValueReq, TagResp tag, User user) throws Exception {
|
||||
if (Objects.nonNull(itemValueReq.getDateConf())) {
|
||||
return;
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.tencent.supersonic.common.pojo.Filter;
|
||||
import com.tencent.supersonic.common.pojo.Order;
|
||||
import com.tencent.supersonic.common.pojo.enums.AggOperatorEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.QueryType;
|
||||
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.TaskStatusEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.TimeDimensionEnum;
|
||||
@@ -241,10 +242,12 @@ public class DictUtils {
|
||||
private SemanticQueryReq constructQueryReq(DictItemResp dictItemResp) {
|
||||
if (TypeEnums.DIMENSION.equals(dictItemResp.getType())) {
|
||||
QuerySqlReq querySqlReq = constructDimQueryReq(dictItemResp);
|
||||
querySqlReq.setQueryType(QueryType.METRIC);
|
||||
return querySqlReq;
|
||||
}
|
||||
if (TypeEnums.TAG.equals(dictItemResp.getType())) {
|
||||
QuerySqlReq querySqlReq = constructTagQueryReq(dictItemResp);
|
||||
querySqlReq.setQueryType(QueryType.TAG);
|
||||
return querySqlReq;
|
||||
}
|
||||
log.warn("constructQueryReq failed");
|
||||
|
||||
@@ -101,6 +101,7 @@ public class TagConverter {
|
||||
// covert to QueryReqConverter
|
||||
QueryStructReq queryStructReq = new QueryStructReq();
|
||||
BeanUtils.copyProperties(queryTagReq, queryStructReq);
|
||||
queryStructReq.setModelIds(queryTagReq.getModelIdSet());
|
||||
if (!CollectionUtils.isEmpty(queryTagReq.getTagFilters())) {
|
||||
queryStructReq.setDimensionFilters(queryTagReq.getTagFilters());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user