mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 11:07:06 +00:00
(improvement)(headless) add checkTag when query tagValue and opt tag convert (#814)
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package com.tencent.supersonic.headless.api.pojo.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.QueryType;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class QuerySqlReq extends SemanticQueryReq {
|
||||
|
||||
private QueryType queryType;
|
||||
private String sql;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.tencent.supersonic.headless.api.pojo.request;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.enums.QueryType;
|
||||
import com.tencent.supersonic.headless.api.pojo.Cache;
|
||||
import com.tencent.supersonic.headless.api.pojo.Param;
|
||||
import lombok.Data;
|
||||
@@ -24,8 +23,6 @@ public abstract class SemanticQueryReq {
|
||||
|
||||
protected String dataSetName;
|
||||
|
||||
protected QueryType queryType;
|
||||
|
||||
protected Set<Long> modelIds = new HashSet<>();
|
||||
|
||||
protected List<Param> params = new ArrayList<>();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -96,13 +96,13 @@ public class TagTest extends BaseTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTagValue() throws Exception {
|
||||
void testTagValue() {
|
||||
TagReq tagReq = newTagReq();
|
||||
tagMetaService.create(tagReq, User.getFakeUser());
|
||||
TagResp tag = queryTagRespByBizName(bizName);
|
||||
ItemValueReq itemValueReq = new ItemValueReq();
|
||||
itemValueReq.setItemId(tag.getId());
|
||||
// tagQueryService.queryTagValue(itemValueReq, User.getFakeUser());
|
||||
// ItemValueResp itemValueResp = tagQueryService.queryTagValue(itemValueReq, User.getFakeUser());
|
||||
tagMetaService.delete(tag.getId(), User.getFakeUser());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user