mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-26 01:34:53 +08:00
(improvement)(headless) Remove redundant user dimensions in demo data (#663)
Co-authored-by: jolunoluo
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
package com.tencent.supersonic.integration;
|
||||
|
||||
import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.NONE;
|
||||
import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.SUM;
|
||||
|
||||
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.QueryFilter;
|
||||
import com.tencent.supersonic.chat.api.pojo.response.ParseResp;
|
||||
@@ -15,13 +12,17 @@ import com.tencent.supersonic.common.pojo.DateConf;
|
||||
import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.QueryType;
|
||||
import com.tencent.supersonic.util.DataUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.NONE;
|
||||
import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.SUM;
|
||||
|
||||
|
||||
public class MetricQueryTest extends BaseQueryTest {
|
||||
@@ -39,6 +40,7 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
expectedParseInfo.setAggType(NONE);
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问次数"));
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("人均访问次数"));
|
||||
|
||||
expectedParseInfo.getDimensionFilters().add(DataUtils.getFilter("user_name",
|
||||
FilterOperatorEnum.EQUALS, "alice", "用户", 2L));
|
||||
@@ -73,7 +75,7 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
expectedParseInfo.setAggType(NONE);
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问次数"));
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("人均访问次数"));
|
||||
expectedParseInfo.setDateInfo(DataUtils.getDateConf(DateConf.DateMode.RECENT, unit, period, startDay, endDay));
|
||||
expectedParseInfo.setQueryType(QueryType.METRIC);
|
||||
|
||||
@@ -102,6 +104,7 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
expectedParseInfo.setAggType(NONE);
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问次数"));
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("人均访问次数"));
|
||||
expectedParseInfo.getDimensions().add(DataUtils.getSchemaElement("部门"));
|
||||
|
||||
expectedParseInfo.setDateInfo(DataUtils.getDateConf(DateConf.DateMode.RECENT, unit, period, startDay, endDay));
|
||||
@@ -122,7 +125,7 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
expectedResult.setQueryMode(MetricFilterQuery.QUERY_MODE);
|
||||
expectedParseInfo.setAggType(NONE);
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问次数"));
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("人均访问次数"));
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("alice");
|
||||
list.add("lucy");
|
||||
@@ -147,9 +150,9 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
expectedParseInfo.setAggType(SUM);
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问次数"));
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("人均访问次数"));
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问用户数"));
|
||||
expectedParseInfo.getDimensions().add(DataUtils.getSchemaElement("用户"));
|
||||
expectedParseInfo.getDimensions().add(DataUtils.getSchemaElement("用户名"));
|
||||
expectedParseInfo.getDimensions().add(DataUtils.getSchemaElement("用户名称"));
|
||||
|
||||
expectedParseInfo.setDateInfo(DataUtils.getDateConf(3, DateConf.DateMode.RECENT, "DAY"));
|
||||
expectedParseInfo.setQueryType(QueryType.METRIC);
|
||||
@@ -168,6 +171,7 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
expectedParseInfo.setAggType(SUM);
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问次数"));
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("人均访问次数"));
|
||||
expectedParseInfo.getDimensions().add(DataUtils.getSchemaElement("部门"));
|
||||
|
||||
expectedParseInfo.setDateInfo(DataUtils.getDateConf(DateConf.DateMode.RECENT, unit, period, startDay, endDay));
|
||||
@@ -193,7 +197,7 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
expectedParseInfo.setAggType(NONE);
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问次数"));
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("人均访问次数"));
|
||||
expectedParseInfo.getDimensionFilters().add(DataUtils.getFilter("user_name",
|
||||
FilterOperatorEnum.EQUALS, "alice", "用户", 2L));
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.tencent.supersonic.integration;
|
||||
|
||||
import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.NONE;
|
||||
|
||||
import com.tencent.supersonic.chat.api.pojo.SchemaElement;
|
||||
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.QueryFilter;
|
||||
@@ -13,15 +11,19 @@ import com.tencent.supersonic.common.pojo.DateConf.DateMode;
|
||||
import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.QueryType;
|
||||
import com.tencent.supersonic.util.DataUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.NONE;
|
||||
|
||||
public class TagQueryTest extends BaseQueryTest {
|
||||
|
||||
@Test
|
||||
public void queryTest_metric_tag_query() throws Exception {
|
||||
QueryResult actualResult = submitNewChat("艺人周杰伦的播放量", null);
|
||||
MockConfiguration.mockTagAgent(agentService);
|
||||
QueryResult actualResult = submitNewChat("艺人周杰伦的播放量", DataUtils.tagAgentId);
|
||||
|
||||
QueryResult expectedResult = new QueryResult();
|
||||
SemanticParseInfo expectedParseInfo = new SemanticParseInfo();
|
||||
@@ -30,7 +32,7 @@ public class TagQueryTest extends BaseQueryTest {
|
||||
expectedResult.setQueryMode(MetricTagQuery.QUERY_MODE);
|
||||
expectedParseInfo.setAggType(NONE);
|
||||
|
||||
QueryFilter dimensionFilter = DataUtils.getFilter("singer_name", FilterOperatorEnum.EQUALS, "周杰伦", "歌手名", 9L);
|
||||
QueryFilter dimensionFilter = DataUtils.getFilter("singer_name", FilterOperatorEnum.EQUALS, "周杰伦", "歌手名", 7L);
|
||||
expectedParseInfo.getDimensionFilters().add(dimensionFilter);
|
||||
|
||||
SchemaElement metric = SchemaElement.builder().name("播放量").build();
|
||||
@@ -44,7 +46,8 @@ public class TagQueryTest extends BaseQueryTest {
|
||||
|
||||
@Test
|
||||
public void queryTest_tag_list_filter() throws Exception {
|
||||
QueryResult actualResult = submitNewChat("爱情、流行类型的艺人", null);
|
||||
MockConfiguration.mockTagAgent(agentService);
|
||||
QueryResult actualResult = submitNewChat("爱情、流行类型的艺人", DataUtils.tagAgentId);
|
||||
|
||||
QueryResult expectedResult = new QueryResult();
|
||||
SemanticParseInfo expectedParseInfo = new SemanticParseInfo();
|
||||
@@ -56,7 +59,7 @@ public class TagQueryTest extends BaseQueryTest {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("流行");
|
||||
QueryFilter dimensionFilter = DataUtils.getFilter("genre", FilterOperatorEnum.EQUALS,
|
||||
"流行", "风格", 8L);
|
||||
"流行", "风格", 6L);
|
||||
expectedParseInfo.getDimensionFilters().add(dimensionFilter);
|
||||
|
||||
SchemaElement metric = SchemaElement.builder().name("播放量").build();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.tencent.supersonic.integration.mapper;
|
||||
|
||||
import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.NONE;
|
||||
|
||||
import com.tencent.supersonic.chat.api.pojo.SchemaElement;
|
||||
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.QueryFilter;
|
||||
@@ -9,21 +7,23 @@ import com.tencent.supersonic.chat.api.pojo.request.QueryReq;
|
||||
import com.tencent.supersonic.chat.api.pojo.response.QueryResult;
|
||||
import com.tencent.supersonic.chat.core.query.rule.metric.MetricTagQuery;
|
||||
import com.tencent.supersonic.common.pojo.DateConf;
|
||||
import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.QueryType;
|
||||
import com.tencent.supersonic.integration.BaseQueryTest;
|
||||
import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum;
|
||||
import com.tencent.supersonic.util.DataUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.NONE;
|
||||
|
||||
public class MapperTest extends BaseQueryTest {
|
||||
|
||||
@Test
|
||||
public void hanlp() throws Exception {
|
||||
|
||||
QueryReq queryContextReq = DataUtils.getQueryContextReq(10, "艺人周杰伦的播放量");
|
||||
queryContextReq.setAgentId(1);
|
||||
queryContextReq.setAgentId(DataUtils.tagAgentId);
|
||||
|
||||
QueryResult actualResult = submitNewChat("艺人周杰伦的播放量", 1);
|
||||
QueryResult actualResult = submitNewChat("艺人周杰伦的播放量", DataUtils.tagAgentId);
|
||||
|
||||
QueryResult expectedResult = new QueryResult();
|
||||
SemanticParseInfo expectedParseInfo = new SemanticParseInfo();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.tencent.supersonic.util;
|
||||
|
||||
import static java.time.LocalDate.now;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
@@ -16,6 +14,8 @@ import com.tencent.supersonic.chat.core.agent.RuleParserTool;
|
||||
import com.tencent.supersonic.common.pojo.DateConf;
|
||||
import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum;
|
||||
|
||||
import static java.time.LocalDate.now;
|
||||
|
||||
public class DataUtils {
|
||||
|
||||
public static final Integer metricAgentId = 1;
|
||||
@@ -106,7 +106,6 @@ public class DataUtils {
|
||||
agent.setDescription("标签圈选");
|
||||
AgentConfig agentConfig = new AgentConfig();
|
||||
agentConfig.getTools().add(getRuleQueryTool());
|
||||
agentConfig.getTools().add(getPluginTool());
|
||||
agent.setAgentConfig(JSONObject.toJSONString(agentConfig));
|
||||
return agent;
|
||||
}
|
||||
@@ -114,8 +113,8 @@ public class DataUtils {
|
||||
private static RuleParserTool getRuleQueryTool() {
|
||||
RuleParserTool ruleQueryTool = new RuleParserTool();
|
||||
ruleQueryTool.setType(AgentToolType.NL2SQL_RULE);
|
||||
ruleQueryTool.setModelIds(Lists.newArrayList(1L, 2L));
|
||||
ruleQueryTool.setQueryModes(Lists.newArrayList("METRIC_ENTITY", "METRIC_FILTER", "METRIC_MODEL",
|
||||
ruleQueryTool.setModelIds(Lists.newArrayList(-1L));
|
||||
ruleQueryTool.setQueryModes(Lists.newArrayList("METRIC_TAG", "METRIC_FILTER", "METRIC_MODEL",
|
||||
"TAG_DETAIL", "TAG_LIST_FILTER", "TAG_ID"));
|
||||
return ruleQueryTool;
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@ dean _1_2 36
|
||||
john _1_2 50
|
||||
jack _1_2 38
|
||||
admin _1_2 70
|
||||
周杰伦 _4_9 100
|
||||
陈奕迅 _4_9 100
|
||||
林俊杰 _4_9 100
|
||||
张碧晨 _4_9 100
|
||||
程响 _4_9 100
|
||||
Taylor#Swift _4_9 100
|
||||
内地 _4_6 100
|
||||
欧美 _4_6 100
|
||||
港台 _4_6 100
|
||||
流行 _4_8 100
|
||||
国风 _4_8 100
|
||||
周杰伦 _4_7 100
|
||||
陈奕迅 _4_7 100
|
||||
林俊杰 _4_7 100
|
||||
张碧晨 _4_7 100
|
||||
程响 _4_7 100
|
||||
Taylor#Swift _4_7 100
|
||||
内地 _4_4 100
|
||||
欧美 _4_4 100
|
||||
港台 _4_4 100
|
||||
流行 _4_6 100
|
||||
国风 _4_6 100
|
||||
@@ -1,6 +1,6 @@
|
||||
p1 _3_4 52
|
||||
p2 _3_4 47
|
||||
p3 _3_4 31
|
||||
p4 _3_4 36
|
||||
p5 _3_4 50
|
||||
p6 _3_4 38
|
||||
p1 _3_3 52
|
||||
p2 _3_3 47
|
||||
p3 _3_3 31
|
||||
p4 _3_3 36
|
||||
p5 _3_3 50
|
||||
p6 _3_3 38
|
||||
@@ -1,9 +1,9 @@
|
||||
周杰伦 _4_9 9000
|
||||
周深 _4_9 8000
|
||||
周传雄 _4_9 7000
|
||||
周华建 _4_9 6000
|
||||
陈奕迅 _4_9 8000
|
||||
林俊杰 _4_9 7000
|
||||
张碧晨 _4_9 7000
|
||||
程响 _4_9 7000
|
||||
Taylor#Swift _4_9 7000
|
||||
周杰伦 _4_7 9000
|
||||
周深 _4_7 8000
|
||||
周传雄 _4_7 7000
|
||||
周华建 _4_7 6000
|
||||
陈奕迅 _4_7 8000
|
||||
林俊杰 _4_7 7000
|
||||
张碧晨 _4_7 7000
|
||||
程响 _4_7 7000
|
||||
Taylor#Swift _4_7 7000
|
||||
@@ -1,4 +1,4 @@
|
||||
美国 _5_10 1
|
||||
加拿大 _5_10 1
|
||||
锡尔赫特、吉大港、库斯蒂亚 _5_10 1
|
||||
孟加拉国 _5_10 3
|
||||
美国 _5_8 1
|
||||
加拿大 _5_8 1
|
||||
锡尔赫特、吉大港、库斯蒂亚 _5_8 1
|
||||
孟加拉国 _5_8 3
|
||||
@@ -1,6 +1,6 @@
|
||||
现代 _5_11 1
|
||||
tagore _5_11 1
|
||||
蓝调 _5_11 1
|
||||
流行 _5_11 1
|
||||
民间 _5_11 1
|
||||
nazrul _5_11 1
|
||||
现代 _5_9 1
|
||||
tagore _5_9 1
|
||||
蓝调 _5_9 1
|
||||
流行 _5_9 1
|
||||
民间 _5_9 1
|
||||
nazrul _5_9 1
|
||||
@@ -1,4 +1,4 @@
|
||||
美国 _6_12 1
|
||||
印度 _6_12 2
|
||||
英国 _6_12 1
|
||||
孟加拉国 _6_12 2
|
||||
美国 _6_10 1
|
||||
印度 _6_10 2
|
||||
英国 _6_10 1
|
||||
孟加拉国 _6_10 2
|
||||
@@ -1,2 +1,2 @@
|
||||
男性 _6_13 3
|
||||
女性 _6_13 3
|
||||
男性 _6_11 3
|
||||
女性 _6_11 3
|
||||
@@ -1,2 +1,2 @@
|
||||
mp4 _7_16 4
|
||||
mp3 _7_16 2
|
||||
mp4 _7_14 4
|
||||
mp3 _7_14 2
|
||||
@@ -1,4 +1,4 @@
|
||||
美国 _8_18 1
|
||||
印度 _8_18 2
|
||||
英国 _8_18 1
|
||||
孟加拉国 _8_18 2
|
||||
美国 _8_16 1
|
||||
印度 _8_16 2
|
||||
英国 _8_16 1
|
||||
孟加拉国 _8_16 2
|
||||
@@ -1,2 +1,2 @@
|
||||
英文 _8_19 2
|
||||
孟加拉语 _8_19 4
|
||||
英文 _8_17 2
|
||||
孟加拉语 _8_17 4
|
||||
@@ -1,6 +1,6 @@
|
||||
阿米·奥帕尔·霍伊 _8_21 1
|
||||
我的爱 _8_21 1
|
||||
打败它 _8_21 1
|
||||
阿杰伊阿卡什 _8_21 1
|
||||
Tumi#长袍#尼罗布 _8_21 1
|
||||
舒克诺#帕塔尔#努普尔#帕埃 _8_21 1
|
||||
阿米·奥帕尔·霍伊 _8_19 1
|
||||
我的爱 _8_19 1
|
||||
打败它 _8_19 1
|
||||
阿杰伊阿卡什 _8_19 1
|
||||
Tumi#长袍#尼罗布 _8_19 1
|
||||
舒克诺#帕塔尔#努普尔#帕埃 _8_19 1
|
||||
Reference in New Issue
Block a user