mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-15 22:46:49 +00:00
[improvement][headless]Clean code logic of headless translator.
This commit is contained in:
@@ -383,9 +383,9 @@ public class S2VisitsDemo extends S2BaseDemo {
|
||||
metricReq.setDescription("访问的用户个数");
|
||||
metricReq.setAlias("UV,访问人数");
|
||||
MetricDefineByFieldParams metricTypeParams = new MetricDefineByFieldParams();
|
||||
metricTypeParams.setExpr("count(distinct user_id)");
|
||||
metricTypeParams.setExpr("count(distinct user_name)");
|
||||
List<FieldParam> fieldParams = new ArrayList<>();
|
||||
fieldParams.add(new FieldParam("user_id"));
|
||||
fieldParams.add(new FieldParam("user_name"));
|
||||
metricTypeParams.setFields(fieldParams);
|
||||
metricReq.setMetricDefineByFieldParams(metricTypeParams);
|
||||
metricReq.setMetricDefineType(MetricDefineType.FIELD);
|
||||
|
||||
@@ -58,6 +58,7 @@ public class QueryByMetricTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void testWithMetricAndDimensionIds() throws Exception {
|
||||
System.setProperty("s2.test", "true");
|
||||
QueryMetricReq queryMetricReq = new QueryMetricReq();
|
||||
queryMetricReq.setDomainId(1L);
|
||||
queryMetricReq.setMetricIds(Arrays.asList(1L, 3L));
|
||||
|
||||
@@ -18,7 +18,7 @@ public class TranslateTest extends BaseTest {
|
||||
public void testSqlExplain() throws Exception {
|
||||
String sql = "SELECT 部门, SUM(访问次数) AS 访问次数 FROM 超音数PVUV统计 GROUP BY 部门 ";
|
||||
SemanticTranslateResp explain = semanticLayerService.translate(
|
||||
QueryReqBuilder.buildS2SQLReq(sql, DataUtils.getMetricAgentView()),
|
||||
QueryReqBuilder.buildS2SQLReq(sql, DataUtils.productDatasetId),
|
||||
User.getDefaultUser());
|
||||
assertNotNull(explain);
|
||||
assertNotNull(explain.getQuerySQL());
|
||||
|
||||
@@ -18,6 +18,11 @@ public class DataUtils {
|
||||
public static final Integer productAgentId = 1;
|
||||
public static final Integer companyAgentId = 2;
|
||||
public static final Integer singerAgentId = 3;
|
||||
|
||||
public static final Long productDatasetId = 1L;
|
||||
public static final Long companyDatasetId = 2L;
|
||||
public static final Long singerDatasettId = 3L;
|
||||
|
||||
public static final Integer ONE_TURNS_CHAT_ID = 10;
|
||||
private static final User user_test = User.getDefaultUser();
|
||||
|
||||
@@ -92,7 +97,4 @@ public class DataUtils {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Long getMetricAgentView() {
|
||||
return 1L;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user