mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 19:51:00 +00:00
Merge pull request #139 from lxwcodemonkey/feature/modelDemoData
Feature/create model and benchmark demo data through api instead of data-h2.sql
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -16,4 +16,5 @@ assembly/runtime/*
|
||||
/runtime
|
||||
**/.flattened-pom.xml
|
||||
chm_db/
|
||||
__pycache__/
|
||||
__pycache__/
|
||||
/dict
|
||||
@@ -10,7 +10,7 @@ public interface AuthService {
|
||||
|
||||
List<AuthGroup> queryAuthGroups(String domainId, Integer groupId);
|
||||
|
||||
void updateAuthGroup(AuthGroup group);
|
||||
void addOrUpdateAuthGroup(AuthGroup group);
|
||||
|
||||
void removeAuthGroup(AuthGroup group);
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class AuthServiceImpl implements AuthService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAuthGroup(AuthGroup group) {
|
||||
public void addOrUpdateAuthGroup(AuthGroup group) {
|
||||
Gson g = new Gson();
|
||||
if (group.getGroupId() == null) {
|
||||
int nextGroupId = 1;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class AuthController {
|
||||
@PostMapping("/createGroup")
|
||||
public void newAuthGroup(@RequestBody AuthGroup group) {
|
||||
group.setGroupId(null);
|
||||
authService.updateAuthGroup(group);
|
||||
authService.addOrUpdateAuthGroup(group);
|
||||
}
|
||||
|
||||
@PostMapping("/removeGroup")
|
||||
@@ -58,7 +58,7 @@ public class AuthController {
|
||||
if (group.getGroupId() == null || group.getGroupId() == 0) {
|
||||
throw new RuntimeException("groupId is empty");
|
||||
}
|
||||
authService.updateAuthGroup(group);
|
||||
authService.addOrUpdateAuthGroup(group);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,8 +7,8 @@ import com.tencent.supersonic.knowledge.service.WordService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -17,7 +17,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ApplicationStartedListener implements ApplicationListener<ApplicationStartedEvent> {
|
||||
@Order(5)
|
||||
public class ApplicationStartedListener implements CommandLineRunner {
|
||||
|
||||
@Autowired
|
||||
private KnowledgeService knowledgeService;
|
||||
@@ -27,7 +28,7 @@ public class ApplicationStartedListener implements ApplicationListener<Applicati
|
||||
private SchemaService schemaService;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationStartedEvent event) {
|
||||
public void run(String... args) {
|
||||
updateKnowledgeDimValue();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,18 +4,13 @@ import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.tencent.supersonic.chat.api.component.SemanticLayer;
|
||||
import com.tencent.supersonic.chat.api.pojo.ModelSchema;
|
||||
import com.tencent.supersonic.common.pojo.ResultData;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.QueryResultWithSchemaResp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@Slf4j
|
||||
@@ -24,10 +19,6 @@ public abstract class BaseSemanticLayer implements SemanticLayer {
|
||||
protected final Cache<String, List<ModelSchemaResp>> modelSchemaCache =
|
||||
CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.SECONDS).build();
|
||||
|
||||
protected ParameterizedTypeReference<ResultData<QueryResultWithSchemaResp>> structTypeRef =
|
||||
new ParameterizedTypeReference<ResultData<QueryResultWithSchemaResp>>() {
|
||||
};
|
||||
|
||||
@SneakyThrows
|
||||
public List<ModelSchemaResp> fetchModelSchema(List<Long> ids, Boolean cacheEnable) {
|
||||
if (cacheEnable) {
|
||||
|
||||
@@ -10,7 +10,7 @@ public enum AggOperatorEnum {
|
||||
|
||||
SUM("SUM"),
|
||||
|
||||
DISTINCT("DISTINCT"),
|
||||
COUNT_DISTINCT("COUNT_DISTINCT"),
|
||||
|
||||
TOPN("TOPN"),
|
||||
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
package com.tencent.supersonic;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.common.pojo.enums.AggOperatorEnum;
|
||||
import com.tencent.supersonic.semantic.api.model.enums.DimensionTypeEnum;
|
||||
import com.tencent.supersonic.semantic.api.model.enums.IdentifyTypeEnum;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.Dim;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.DimensionTimeTypeParams;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.Identify;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.Measure;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DatasourceReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DomainReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.ModelReq;
|
||||
import com.tencent.supersonic.semantic.model.domain.DatasourceService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DomainService;
|
||||
import com.tencent.supersonic.semantic.model.domain.ModelService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@Order(2)
|
||||
public class LoadBenchMarkDemo implements CommandLineRunner {
|
||||
|
||||
private User user = User.getFakeUser();
|
||||
|
||||
@Value("${spring.h2.demo.enabled:false}")
|
||||
private boolean demoEnable;
|
||||
|
||||
@Autowired
|
||||
private DomainService domainService;
|
||||
@Autowired
|
||||
private ModelService modelService;
|
||||
@Autowired
|
||||
private DatasourceService datasourceService;
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
if (!demoEnable) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
addDomain();
|
||||
addModel_1();
|
||||
addDatasource_1();
|
||||
addDatasource_2();
|
||||
addDatasource_3();
|
||||
addDatasource_4();
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to add bench mark demo data", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addDomain() {
|
||||
DomainReq domainReq = new DomainReq();
|
||||
domainReq.setName("测评数据-音乐");
|
||||
domainReq.setBizName("music");
|
||||
domainReq.setParentId(0L);
|
||||
domainReq.setViewers(Arrays.asList("admin", "tom", "jack"));
|
||||
domainReq.setViewOrgs(Collections.singletonList("admin"));
|
||||
domainReq.setAdmins(Collections.singletonList("admin"));
|
||||
domainReq.setAdminOrgs(Collections.emptyList());
|
||||
domainService.createDomain(domainReq, user);
|
||||
}
|
||||
|
||||
public void addModel_1() {
|
||||
ModelReq modelReq = new ModelReq();
|
||||
modelReq.setName("测评数据-音乐");
|
||||
modelReq.setBizName("music");
|
||||
modelReq.setDomainId(2L);
|
||||
modelReq.setViewers(Arrays.asList("admin", "tom", "jack"));
|
||||
modelReq.setViewOrgs(Collections.singletonList("admin"));
|
||||
modelReq.setAdmins(Collections.singletonList("admin"));
|
||||
modelReq.setAdminOrgs(Collections.emptyList());
|
||||
modelService.createModel(modelReq, user);
|
||||
}
|
||||
|
||||
public void addDatasource_1() throws Exception {
|
||||
DatasourceReq datasourceReq = new DatasourceReq();
|
||||
datasourceReq.setModelId(3L);
|
||||
datasourceReq.setName("艺术类型");
|
||||
datasourceReq.setBizName("genre");
|
||||
datasourceReq.setDescription("艺术类型");
|
||||
datasourceReq.setDatabaseId(1L);
|
||||
|
||||
List<Dim> dimensions = new ArrayList<>();
|
||||
Dim dimension1 = new Dim("", "imp_date", DimensionTypeEnum.time.name(), 0);
|
||||
dimension1.setTypeParams(new DimensionTimeTypeParams());
|
||||
dimensions.add(dimension1);
|
||||
dimensions.add(new Dim("活跃区域", "most_popular_in", DimensionTypeEnum.categorical.name(), 1));
|
||||
datasourceReq.setDimensions(dimensions);
|
||||
|
||||
List<Identify> identifiers = new ArrayList<>();
|
||||
identifiers.add(new Identify("音乐类型名称", IdentifyTypeEnum.primary.name(), "g_name"));
|
||||
datasourceReq.setIdentifiers(identifiers);
|
||||
|
||||
List<Measure> measures = new ArrayList<>();
|
||||
Measure measure = new Measure("评分", "rating", AggOperatorEnum.SUM.name(), 0);
|
||||
measures.add(measure);
|
||||
datasourceReq.setMeasures(measures);
|
||||
|
||||
datasourceReq.setQueryType("sql_query");
|
||||
datasourceReq.setSqlQuery("SELECT g_name, rating, most_popular_in FROM genre");
|
||||
datasourceService.createDatasource(datasourceReq, user);
|
||||
}
|
||||
|
||||
public void addDatasource_2() throws Exception {
|
||||
DatasourceReq datasourceReq = new DatasourceReq();
|
||||
datasourceReq.setModelId(3L);
|
||||
datasourceReq.setName("艺术家");
|
||||
datasourceReq.setBizName("artist");
|
||||
datasourceReq.setDescription("艺术家");
|
||||
datasourceReq.setDatabaseId(1L);
|
||||
|
||||
List<Dim> dimensions = new ArrayList<>();
|
||||
dimensions.add(new Dim("国籍", "country", DimensionTypeEnum.categorical.name(), 1));
|
||||
dimensions.add(new Dim("性别", "gender", DimensionTypeEnum.categorical.name(), 1));
|
||||
datasourceReq.setDimensions(dimensions);
|
||||
|
||||
List<Identify> identifiers = new ArrayList<>();
|
||||
identifiers.add(new Identify("艺术家名称", IdentifyTypeEnum.primary.name(), "artist_name"));
|
||||
identifiers.add(new Identify("音乐类型名称", IdentifyTypeEnum.foreign.name(), "g_name"));
|
||||
datasourceReq.setIdentifiers(identifiers);
|
||||
|
||||
datasourceReq.setMeasures(Collections.emptyList());
|
||||
|
||||
datasourceReq.setQueryType("sql_query");
|
||||
datasourceReq.setSqlQuery("SELECT artist_name, country, gender, g_name FROM artist");
|
||||
datasourceService.createDatasource(datasourceReq, user);
|
||||
}
|
||||
|
||||
public void addDatasource_3() throws Exception {
|
||||
DatasourceReq datasourceReq = new DatasourceReq();
|
||||
datasourceReq.setModelId(3L);
|
||||
datasourceReq.setName("文件");
|
||||
datasourceReq.setBizName("files");
|
||||
datasourceReq.setDescription("文件");
|
||||
datasourceReq.setDatabaseId(1L);
|
||||
|
||||
List<Dim> dimensions = new ArrayList<>();
|
||||
dimensions.add(new Dim("持续时间", "duration", DimensionTypeEnum.categorical.name(), 1));
|
||||
dimensions.add(new Dim("文件格式", "formats", DimensionTypeEnum.categorical.name(), 1));
|
||||
datasourceReq.setDimensions(dimensions);
|
||||
|
||||
List<Identify> identifiers = new ArrayList<>();
|
||||
identifiers.add(new Identify("歌曲ID", IdentifyTypeEnum.primary.name(), "f_id"));
|
||||
identifiers.add(new Identify("艺术家名称", IdentifyTypeEnum.foreign.name(), "artist_name"));
|
||||
datasourceReq.setIdentifiers(identifiers);
|
||||
|
||||
datasourceReq.setMeasures(Collections.emptyList());
|
||||
|
||||
datasourceReq.setQueryType("sql_query");
|
||||
datasourceReq.setSqlQuery("SELECT f_id, artist_name, file_size, duration, formats FROM files");
|
||||
datasourceService.createDatasource(datasourceReq, user);
|
||||
}
|
||||
|
||||
public void addDatasource_4() throws Exception {
|
||||
DatasourceReq datasourceReq = new DatasourceReq();
|
||||
datasourceReq.setModelId(3L);
|
||||
datasourceReq.setName("歌曲");
|
||||
datasourceReq.setBizName("song");
|
||||
datasourceReq.setDescription("歌曲");
|
||||
datasourceReq.setDatabaseId(1L);
|
||||
|
||||
List<Dim> dimensions = new ArrayList<>();
|
||||
Dim dimension1 = new Dim("", "imp_date", DimensionTypeEnum.time.name(), 0);
|
||||
dimension1.setTypeParams(new DimensionTimeTypeParams());
|
||||
dimensions.add(dimension1);
|
||||
dimensions.add(new Dim("国家", "country", DimensionTypeEnum.categorical.name(), 1));
|
||||
dimensions.add(new Dim("语种", "languages", DimensionTypeEnum.categorical.name(), 1));
|
||||
dimensions.add(new Dim("发行时间", "releasedate", DimensionTypeEnum.categorical.name(), 1));
|
||||
datasourceReq.setDimensions(dimensions);
|
||||
|
||||
List<Identify> identifiers = new ArrayList<>();
|
||||
identifiers.add(new Identify("歌曲名称", IdentifyTypeEnum.primary.name(), "song_name"));
|
||||
identifiers.add(new Identify("歌曲ID", IdentifyTypeEnum.foreign.name(), "f_id"));
|
||||
datasourceReq.setIdentifiers(identifiers);
|
||||
|
||||
List<Measure> measures = new ArrayList<>();
|
||||
measures.add(new Measure("分辨率", "resolution", AggOperatorEnum.SUM.name(), 1));
|
||||
measures.add(new Measure("评分", "rating", AggOperatorEnum.SUM.name(), 1));
|
||||
datasourceReq.setMeasures(measures);
|
||||
|
||||
datasourceReq.setQueryType("sql_query");
|
||||
datasourceReq.setSqlQuery("SELECT imp_date, song_name, artist_name, country, f_id, g_name, "
|
||||
+ " rating, languages, releasedate, resolution FROM song");
|
||||
datasourceService.createDatasource(datasourceReq, user);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
package com.tencent.supersonic;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.auth.api.authorization.pojo.AuthGroup;
|
||||
import com.tencent.supersonic.auth.api.authorization.pojo.AuthRule;
|
||||
import com.tencent.supersonic.auth.api.authorization.service.AuthService;
|
||||
import com.tencent.supersonic.common.pojo.enums.AggOperatorEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.SensitiveLevelEnum;
|
||||
import com.tencent.supersonic.semantic.api.model.enums.DimensionTypeEnum;
|
||||
import com.tencent.supersonic.semantic.api.model.enums.IdentifyTypeEnum;
|
||||
import com.tencent.supersonic.semantic.api.model.enums.SemanticTypeEnum;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.Dim;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.DimensionTimeTypeParams;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.Entity;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.Identify;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.Measure;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.MetricTypeParams;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DatabaseReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DatasourceReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DimensionReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DomainReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.MetricReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.ModelReq;
|
||||
import com.tencent.supersonic.semantic.model.domain.DatabaseService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DatasourceService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DimensionService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DomainService;
|
||||
import com.tencent.supersonic.semantic.model.domain.MetricService;
|
||||
import com.tencent.supersonic.semantic.model.domain.ModelService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@Order(1)
|
||||
public class LoadModelDataDemo implements CommandLineRunner {
|
||||
|
||||
private User user = User.getFakeUser();
|
||||
|
||||
@Value("${spring.h2.demo.enabled:false}")
|
||||
private boolean demoEnable;
|
||||
|
||||
@Autowired
|
||||
private DatabaseService databaseService;
|
||||
@Autowired
|
||||
private DomainService domainService;
|
||||
@Autowired
|
||||
private ModelService modelService;
|
||||
@Autowired
|
||||
private DatasourceService datasourceService;
|
||||
@Autowired
|
||||
private DimensionService dimensionService;
|
||||
@Autowired
|
||||
private MetricService metricService;
|
||||
@Autowired
|
||||
private AuthService authService;
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
if (!demoEnable) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
addDatabase();
|
||||
addDomain();
|
||||
addModel_1();
|
||||
addDatasource_1();
|
||||
addDatasource_2();
|
||||
addDatasource_3();
|
||||
addModel_2();
|
||||
addDatasource_4();
|
||||
updateDimension();
|
||||
updateMetric();
|
||||
addAuthGroup_1();
|
||||
addAuthGroup_2();
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to add model demo data", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addDatabase() {
|
||||
DatabaseReq databaseReq = new DatabaseReq();
|
||||
databaseReq.setName("H2数据实例");
|
||||
databaseReq.setDescription("样例数据库实例");
|
||||
databaseReq.setType("h2");
|
||||
databaseReq.setUrl("jdbc:h2:mem:semantic;DATABASE_TO_UPPER=false");
|
||||
databaseReq.setUsername("root");
|
||||
databaseReq.setPassword("semantic");
|
||||
databaseService.createOrUpdateDatabase(databaseReq, user);
|
||||
}
|
||||
|
||||
public void addDomain() {
|
||||
DomainReq domainReq = new DomainReq();
|
||||
domainReq.setName("超音数");
|
||||
domainReq.setBizName("supersonic");
|
||||
domainReq.setParentId(0L);
|
||||
domainReq.setViewers(Arrays.asList("admin", "tom", "jack"));
|
||||
domainReq.setViewOrgs(Collections.singletonList("admin"));
|
||||
domainReq.setAdmins(Collections.singletonList("admin"));
|
||||
domainReq.setAdminOrgs(Collections.emptyList());
|
||||
domainService.createDomain(domainReq, user);
|
||||
}
|
||||
|
||||
public void addModel_1() {
|
||||
ModelReq modelReq = new ModelReq();
|
||||
modelReq.setName("超音数");
|
||||
modelReq.setBizName("supersonic");
|
||||
modelReq.setDomainId(1L);
|
||||
modelReq.setViewers(Arrays.asList("admin", "tom", "jack"));
|
||||
modelReq.setViewOrgs(Collections.singletonList("admin"));
|
||||
modelReq.setAdmins(Collections.singletonList("admin"));
|
||||
modelReq.setAdminOrgs(Collections.emptyList());
|
||||
modelService.createModel(modelReq, user);
|
||||
}
|
||||
|
||||
public void addDatasource_1() throws Exception {
|
||||
DatasourceReq datasourceReq = new DatasourceReq();
|
||||
datasourceReq.setName("用户部门");
|
||||
datasourceReq.setBizName("user_department");
|
||||
datasourceReq.setDescription("用户部门");
|
||||
datasourceReq.setDatabaseId(1L);
|
||||
|
||||
List<Identify> identifiers = new ArrayList<>();
|
||||
identifiers.add(new Identify("用户名", IdentifyTypeEnum.primary.name(), "user_name"));
|
||||
datasourceReq.setIdentifiers(identifiers);
|
||||
|
||||
List<Dim> dimensions = new ArrayList<>();
|
||||
dimensions.add(new Dim("部门", "department",
|
||||
DimensionTypeEnum.categorical.name(), 1));
|
||||
datasourceReq.setDimensions(dimensions);
|
||||
|
||||
datasourceReq.setMeasures(Collections.emptyList());
|
||||
datasourceReq.setQueryType("table_query");
|
||||
datasourceReq.setTableQuery("PUBLIC.s2_user_department");
|
||||
datasourceReq.setModelId(1L);
|
||||
datasourceService.createDatasource(datasourceReq, user);
|
||||
}
|
||||
|
||||
public void addDatasource_2() throws Exception {
|
||||
DatasourceReq datasourceReq = new DatasourceReq();
|
||||
datasourceReq.setName("PVUV统计");
|
||||
datasourceReq.setBizName("s2_pv_uv_statis");
|
||||
datasourceReq.setDescription("PVUV统计");
|
||||
datasourceReq.setDatabaseId(1L);
|
||||
|
||||
List<Identify> identifiers = new ArrayList<>();
|
||||
identifiers.add(new Identify("用户名", IdentifyTypeEnum.primary.name(), "user_name"));
|
||||
datasourceReq.setIdentifiers(identifiers);
|
||||
|
||||
List<Dim> dimensions = new ArrayList<>();
|
||||
Dim dimension1 = new Dim("", "imp_date", DimensionTypeEnum.time.name(), 0);
|
||||
dimension1.setTypeParams(new DimensionTimeTypeParams());
|
||||
dimensions.add(dimension1);
|
||||
Dim dimension2 = new Dim("", "page", DimensionTypeEnum.categorical.name(), 0);
|
||||
dimensions.add(dimension2);
|
||||
datasourceReq.setDimensions(dimensions);
|
||||
|
||||
List<Measure> measures = new ArrayList<>();
|
||||
Measure measure1 = new Measure("访问次数", "pv", AggOperatorEnum.SUM.name(), 1);
|
||||
measures.add(measure1);
|
||||
|
||||
Measure measure2 = new Measure("访问人数", "uv", AggOperatorEnum.COUNT_DISTINCT.name(), 1);
|
||||
measures.add(measure2);
|
||||
|
||||
datasourceReq.setMeasures(measures);
|
||||
datasourceReq.setSqlQuery("SELECT imp_date, user_name, page, 1 as pv, user_name as uv FROM s2_pv_uv_statis");
|
||||
datasourceReq.setQueryType("sql_query");
|
||||
datasourceReq.setModelId(1L);
|
||||
datasourceService.createDatasource(datasourceReq, user);
|
||||
}
|
||||
|
||||
public void addDatasource_3() throws Exception {
|
||||
DatasourceReq datasourceReq = new DatasourceReq();
|
||||
datasourceReq.setName("停留时长统计");
|
||||
datasourceReq.setBizName("s2_stay_time_statis");
|
||||
datasourceReq.setDescription("停留时长统计");
|
||||
datasourceReq.setDatabaseId(1L);
|
||||
|
||||
List<Identify> identifiers = new ArrayList<>();
|
||||
identifiers.add(new Identify("用户名", IdentifyTypeEnum.primary.name(), "user_name"));
|
||||
datasourceReq.setIdentifiers(identifiers);
|
||||
|
||||
List<Dim> dimensions = new ArrayList<>();
|
||||
Dim dimension1 = new Dim("", "imp_date", DimensionTypeEnum.time.name(), 0);
|
||||
dimension1.setTypeParams(new DimensionTimeTypeParams());
|
||||
dimensions.add(dimension1);
|
||||
Dim dimension2 = new Dim("页面", "page", DimensionTypeEnum.categorical.name(), 1);
|
||||
dimensions.add(dimension2);
|
||||
datasourceReq.setDimensions(dimensions);
|
||||
|
||||
List<Measure> measures = new ArrayList<>();
|
||||
Measure measure1 = new Measure("停留时长", "stay_hours", AggregateTypeEnum.SUM.name(), 1);
|
||||
measures.add(measure1);
|
||||
|
||||
datasourceReq.setMeasures(measures);
|
||||
datasourceReq.setTableQuery("PUBLIC.s2_stay_time_statis");
|
||||
datasourceReq.setQueryType("table_query");
|
||||
datasourceReq.setModelId(1L);
|
||||
datasourceService.createDatasource(datasourceReq, user);
|
||||
}
|
||||
|
||||
public void addModel_2() {
|
||||
ModelReq modelReq = new ModelReq();
|
||||
modelReq.setName("艺人库");
|
||||
modelReq.setBizName("singer");
|
||||
modelReq.setDomainId(1L);
|
||||
modelReq.setViewers(Arrays.asList("admin", "tom", "jack"));
|
||||
modelReq.setViewOrgs(Collections.singletonList("admin"));
|
||||
modelReq.setAdmins(Collections.singletonList("admin"));
|
||||
modelReq.setAdminOrgs(Collections.emptyList());
|
||||
modelReq.setEntity(new Entity(7L, Arrays.asList("歌手", "艺人")));
|
||||
modelService.createModel(modelReq, user);
|
||||
}
|
||||
|
||||
public void addDatasource_4() throws Exception {
|
||||
DatasourceReq datasourceReq = new DatasourceReq();
|
||||
datasourceReq.setName("艺人库");
|
||||
datasourceReq.setBizName("singer");
|
||||
datasourceReq.setDescription("艺人库");
|
||||
datasourceReq.setDatabaseId(1L);
|
||||
|
||||
List<Identify> identifiers = new ArrayList<>();
|
||||
identifiers.add(new Identify("歌手名", IdentifyTypeEnum.primary.name(), "singer_name"));
|
||||
datasourceReq.setIdentifiers(identifiers);
|
||||
|
||||
List<Dim> dimensions = new ArrayList<>();
|
||||
Dim dimension1 = new Dim("", "imp_date", DimensionTypeEnum.time.name(), 0);
|
||||
dimension1.setTypeParams(new DimensionTimeTypeParams());
|
||||
dimensions.add(dimension1);
|
||||
dimensions.add(new Dim("活跃区域", "act_area",
|
||||
DimensionTypeEnum.categorical.name(), 1));
|
||||
dimensions.add(new Dim("代表作", "song_name",
|
||||
DimensionTypeEnum.categorical.name(), 1));
|
||||
dimensions.add(new Dim("风格", "genre",
|
||||
DimensionTypeEnum.categorical.name(), 1));
|
||||
datasourceReq.setDimensions(dimensions);
|
||||
|
||||
Measure measure1 = new Measure("播放量", "js_play_cnt", "sum", 1);
|
||||
Measure measure2 = new Measure("下载量", "down_cnt", "sum", 1);
|
||||
Measure measure3 = new Measure("收藏量", "favor_cnt", "sum", 1);
|
||||
datasourceReq.setMeasures(Lists.newArrayList(measure1, measure2, measure3));
|
||||
datasourceReq.setQueryType("table_query");
|
||||
datasourceReq.setTableQuery("PUBLIC.singer");
|
||||
datasourceReq.setModelId(2L);
|
||||
datasourceService.createDatasource(datasourceReq, user);
|
||||
}
|
||||
|
||||
public void updateDimension() throws Exception {
|
||||
DimensionReq dimensionReq = new DimensionReq();
|
||||
dimensionReq.setModelId(1L);
|
||||
dimensionReq.setType(DimensionTypeEnum.categorical.name());
|
||||
dimensionReq.setId(3L);
|
||||
dimensionReq.setName("页面");
|
||||
dimensionReq.setBizName("page");
|
||||
dimensionReq.setDatasourceId(3L);
|
||||
dimensionReq.setAlias("page");
|
||||
dimensionReq.setSemanticType(SemanticTypeEnum.CATEGORY.name());
|
||||
dimensionReq.setSensitiveLevel(2);
|
||||
dimensionReq.setDescription("页面");
|
||||
dimensionReq.setExpr("page");
|
||||
dimensionReq.setDimValueMaps(Collections.emptyList());
|
||||
dimensionService.updateDimension(dimensionReq, user);
|
||||
}
|
||||
|
||||
public void updateMetric() throws Exception {
|
||||
MetricReq metricReq = new MetricReq();
|
||||
metricReq.setModelId(1L);
|
||||
metricReq.setId(3L);
|
||||
metricReq.setName("停留时长");
|
||||
metricReq.setBizName("stay_hours");
|
||||
metricReq.setSensitiveLevel(SensitiveLevelEnum.HIGH.getCode());
|
||||
metricReq.setDescription("停留时长");
|
||||
metricReq.setTags(Collections.singletonList("核心指标"));
|
||||
metricReq.setAlias("访问时长");
|
||||
MetricTypeParams metricTypeParams = new MetricTypeParams();
|
||||
metricTypeParams.setExpr("s2_stay_time_statis_stay_hours");
|
||||
List<Measure> measures = new ArrayList<>();
|
||||
Measure measure = new Measure("停留时长",
|
||||
"s2_stay_time_statis_stay_hours", AggOperatorEnum.SUM.getOperator(), 1);
|
||||
measure.setDatasourceId(3L);
|
||||
measures.add(measure);
|
||||
metricTypeParams.setMeasures(measures);
|
||||
metricReq.setTypeParams(metricTypeParams);
|
||||
metricService.updateExprMetric(metricReq, user);
|
||||
}
|
||||
|
||||
public void addAuthGroup_1() {
|
||||
AuthGroup authGroupReq = new AuthGroup();
|
||||
authGroupReq.setModelId("1");
|
||||
authGroupReq.setName("admin-permission");
|
||||
|
||||
List<AuthRule> authRules = new ArrayList<>();
|
||||
AuthRule authRule = new AuthRule();
|
||||
authRule.setMetrics(Collections.singletonList("stay_hours"));
|
||||
authRule.setDimensions(Collections.singletonList("page"));
|
||||
authRules.add(authRule);
|
||||
|
||||
authGroupReq.setAuthRules(authRules);
|
||||
authGroupReq.setAuthorizedUsers(Collections.singletonList("jack"));
|
||||
authGroupReq.setAuthorizedDepartmentIds(Collections.emptyList());
|
||||
authService.addOrUpdateAuthGroup(authGroupReq);
|
||||
}
|
||||
|
||||
public void addAuthGroup_2() {
|
||||
AuthGroup authGroupReq = new AuthGroup();
|
||||
authGroupReq.setModelId("1");
|
||||
authGroupReq.setName("tom_sales_permission");
|
||||
|
||||
List<AuthRule> authRules = new ArrayList<>();
|
||||
AuthRule authRule = new AuthRule();
|
||||
authRule.setMetrics(Collections.singletonList("stay_hours"));
|
||||
authRule.setDimensions(Collections.singletonList("page"));
|
||||
authRules.add(authRule);
|
||||
|
||||
authGroupReq.setAuthRules(authRules);
|
||||
authGroupReq.setDimensionFilters(Collections.singletonList("department in ('sales')"));
|
||||
authGroupReq.setDimensionFilterDescription("部门 in [sales]");
|
||||
authGroupReq.setAuthorizedUsers(Collections.singletonList("tom"));
|
||||
authGroupReq.setAuthorizedDepartmentIds(Collections.emptyList());
|
||||
authService.addOrUpdateAuthGroup(authGroupReq);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +1,31 @@
|
||||
tagore _3_8 9000
|
||||
nazrul _3_8 9000
|
||||
民间 _3_8 9000
|
||||
现代 _3_8 9000
|
||||
蓝调 _3_8 9000
|
||||
流行 _3_8 9000
|
||||
孟加拉国 _3_8 9000
|
||||
锡尔赫特、吉大港、库斯蒂亚 _3_8 9000
|
||||
加拿大 _3_8 9000
|
||||
美国 _3_8 9000
|
||||
tagore _3_9 9000
|
||||
nazrul _3_9 9000
|
||||
民间 _3_9 9000
|
||||
现代 _3_9 9000
|
||||
蓝调 _3_9 9000
|
||||
流行 _3_9 9000
|
||||
孟加拉国 _3_10 9000
|
||||
锡尔赫特、吉大港、库斯蒂亚 _3_10 9000
|
||||
加拿大 _3_10 9000
|
||||
印度 _3_10 9000
|
||||
美国 _3_10 9000
|
||||
Shrikanta _3_11 9000
|
||||
Prity _3_11 9000
|
||||
Farida _3_11 9000
|
||||
Topu _3_11 9000
|
||||
Enrique _3_11 9000
|
||||
Michel _3_11 9000
|
||||
孟加拉国 _3_12 9000
|
||||
印度 _3_12 9000
|
||||
美国 _3_12 9000
|
||||
英国 _3_12 9000
|
||||
男性 _3_13 9000
|
||||
女性 _3_13 9000
|
||||
mp4 _3_19 9000
|
||||
mp3 _3_19 9000
|
||||
Tumi#长袍#尼罗布 _3_20 9000
|
||||
舒克诺#帕塔尔#努普尔#帕埃 _3_20 9000
|
||||
阿米·奥帕尔·霍伊 _3_20 9000
|
||||
我的爱 _3_20 9000
|
||||
打败它 _3_20 9000
|
||||
阿杰伊阿卡什 _3_20 9000
|
||||
孟加拉国 _3_22 9000
|
||||
印度 _3_22 9000
|
||||
美国 _3_22 9000
|
||||
英国 _3_22 9000
|
||||
孟加拉语 _3_26 9000
|
||||
英文 _3_26 9000
|
||||
英国 _3_10 9000
|
||||
男性 _3_11 9000
|
||||
女性 _3_11 9000
|
||||
Shrikanta _3_12 9000
|
||||
Prity _3_12 9000
|
||||
Farida _3_12 9000
|
||||
Topu _3_12 9000
|
||||
Enrique _3_12 9000
|
||||
Michel _3_12 9000
|
||||
mp4 _3_14 9000
|
||||
mp3 _3_14 9000
|
||||
孟加拉语 _3_16 9000
|
||||
英文 _3_16 9000
|
||||
Tumi#长袍#尼罗布 _3_18 9000
|
||||
舒克诺#帕塔尔#努普尔#帕埃 _3_18 9000
|
||||
阿米·奥帕尔·霍伊 _3_18 9000
|
||||
我的爱 _3_18 9000
|
||||
打败它 _3_18 9000
|
||||
|
||||
@@ -5,32 +5,6 @@ insert into s2_user (id, `name`, password, display_name, email) values (3, 'tom'
|
||||
insert into s2_user (id, `name`, password, display_name, email, is_admin) values (4, 'lucy','123456','lucy','lucy@xx.com', 1);
|
||||
insert into s2_user (id, `name`, password, display_name, email) values (5, 'alice','123456','alice','alice@xx.com');
|
||||
|
||||
-- sample models
|
||||
insert into s2_domain (id, `name`, biz_name, parent_id, status, created_at, created_by, updated_at, updated_by, `admin`, admin_org, viewer, view_org) VALUES(1, '超音数', 'supersonic', 0, 1, '2023-05-24 00:00:00', 'admin', '2023-05-24 00:00:00', 'admin', 'admin', '', 'admin,tom,jack', 'admin' );
|
||||
insert into s2_model (id, `name`, biz_name, domain_id, created_at, created_by, updated_at, updated_by, `admin`, admin_org, is_open, viewer, view_org, entity) VALUES(1, '超音数', 'supersonic', 1, '2023-05-24 00:00:00', 'admin', '2023-05-24 00:00:00', 'admin', 'admin', '', 0, 'admin,tom,jack', 'admin','' );
|
||||
insert into s2_model (id, `name`, biz_name, domain_id, created_at, created_by, updated_at, updated_by, `admin`, admin_org, is_open, viewer, view_org, entity) VALUES(2, '艺人库', 'singer', 1, '2023-05-24 00:00:00', 'admin', '2023-05-24 00:00:00', 'admin', 'admin', '', 0, 'admin,tom,jack', 'admin','{"entityId": 7, "names": ["歌手", "艺人"]}' );
|
||||
insert into s2_database (id, `name`, description, `type` ,config ,created_at ,created_by ,updated_at ,updated_by, `admin`) VALUES(1, 'H2数据实例', '', 'h2', '{"password":"semantic","url":"jdbc:h2:mem:semantic;DATABASE_TO_UPPER=false","userName":"root"}', '2023-05-24 00:00:00', 'admin', '2023-05-24 00:00:00', 'admin', 'admin');
|
||||
insert into s2_datasource (id , model_id, `name`, biz_name, description, database_id ,datasource_detail, created_at, created_by, updated_at, updated_by ) VALUES(1, 1, '停留时长统计', 's2_stay_time_statis', '停留时长统计', 1, '{"dimensions":[{"bizName":"imp_date","dateFormat":"yyyy-MM-dd","expr":"imp_date","isCreateDimension":0,"type":"time","typeParams":{"isPrimary":"true","timeGranularity":"day"}},{"bizName":"page","dateFormat":"yyyy-MM-dd","expr":"page","isCreateDimension":0,"type":"categorical"}],"identifiers":[{"bizName":"user_name","name":"用户名","type":"primary"}],"measures":[{"agg":"sum","bizName":"s2_stay_time_statis_stay_hours","expr":"stay_hours","isCreateMetric":1,"name":"停留时长"}],"queryType":"sql_query","sqlQuery":"SELECT imp_date, page,user_name,stay_hours FROM s2_stay_time_statis"}', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource (id , model_id, `name`, biz_name, description, database_id ,datasource_detail, created_at, created_by, updated_at, updated_by ) VALUES(2, 1, 'PVUV统计', 's2_pv_uv_statis', 'PVUV统计', 1, '{"dimensions":[{"bizName":"imp_date","dateFormat":"yyyy-MM-dd","expr":"imp_date","isCreateDimension":0,"type":"time","typeParams":{"isPrimary":"true","timeGranularity":"day"}},{"bizName":"page","dateFormat":"yyyy-MM-dd","expr":"page","isCreateDimension":0,"type":"categorical"}],"identifiers":[{"bizName":"user_name","name":"用户名","type":"primary"}],"measures":[{"agg":"sum","bizName":"s2_pv_uv_statis_pv","expr":"pv","isCreateMetric":1,"name":"访问次数"},{"agg":"count_distinct","bizName":"s2_pv_uv_statis_uv","expr":"uv","isCreateMetric":1,"name":"访问人数"}],"queryType":"sql_query","sqlQuery":"SELECT imp_date, user_name,page,1 as pv, user_name as uv FROM s2_pv_uv_statis"}', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource (id , model_id, `name`, biz_name, description, database_id ,datasource_detail, created_at, created_by, updated_at, updated_by ) VALUES(3, 1, '用户部门', 'user_department', '用户部门', 1, '{"dimensions":[{"bizName":"department","dateFormat":"yyyy-MM-dd","expr":"department","isCreateDimension":1,"name":"部门","type":"categorical"}],"identifiers":[{"bizName":"user_name","name":"用户名","type":"primary"}],"measures":[],"queryType":"sql_query","sqlQuery":"SELECT user_name,department FROM s2_user_department"}', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource (id , model_id, `name`, biz_name, description, database_id ,datasource_detail, created_at, created_by, updated_at, updated_by ) VALUES(4, 2, '艺人库', 'singer', '艺人库', 1, '{"dimensions":[{"bizName":"imp_date","dateFormat":"yyyy-MM-dd","expr":"imp_date","isCreateDimension":0,"type":"time","typeParams":{"isPrimary":"true","timeGranularity":"day"}},{"bizName":"act_area","dateFormat":"yyyy-MM-dd","expr":"act_area","isCreateDimension":1,"name":"活跃区域","type":"categorical"},{"bizName":"song_name","dateFormat":"yyyy-MM-dd","expr":"song_name","isCreateDimension":1,"name":"代表作","type":"categorical"},{"bizName":"genre","dateFormat":"yyyy-MM-dd","expr":"genre","isCreateDimension":1,"name":"风格","type":"categorical"}],"identifiers":[{"bizName":"singer_name","name":"歌手名","type":"primary"}],"measures":[{"agg":"sum","bizName":"music_down_cnt","expr":"down_cnt","isCreateMetric":1,"name":"下载量"},{"agg":"sum","bizName":"music_js_play_cnt","expr":"js_play_cnt","isCreateMetric":1,"name":"播放量"},{"agg":"sum","bizName":"music_favor_cnt","expr":"favor_cnt","isCreateMetric":1,"name":"收藏量"}],"queryType":"sql_query","sqlQuery":"SELECT imp_date,singer_name,act_area,song_name,genre,js_play_cnt,down_cnt,favor_cnt FROM singer "}', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource_rela (id , model_id, `datasource_from`, datasource_to, join_key, created_at, created_by, updated_at, updated_by ) VALUES(1, 1, 1, 2, 'user_name', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource_rela (id , model_id, `datasource_from`, datasource_to, join_key, created_at, created_by, updated_at, updated_by ) VALUES(2, 1, 1, 3, 'user_name', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource_rela (id , model_id, `datasource_from`, datasource_to, join_key, created_at, created_by, updated_at, updated_by ) VALUES(3, 1, 2, 3, 'user_name', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type, dim_value_maps) VALUES(1, 1, 3, '部门', 'department', '部门', 1, 0, 'categorical', NULL, 'department', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY', '[{"alias":["人力资源","人力"],"bizName":"人力资源","techName":"HR"},{"alias":["营销","销售"],"bizName":"营销部门","techName":"sales"}]');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(2, 1, 1, '用户名', 'user_name', '用户名', 1, 0, 'primary', NULL, 'user_name', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(3, 1, 2, '页面', 'page', '页面', 1, 2, 'categorical', NULL, 'page', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(4, 2, 4, '活跃区域', 'act_area', '活跃区域', 1, 2, 'categorical', NULL, 'act_area', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(5, 2, 4, '代表作', 'song_name', '代表作', 1, 2, 'categorical', NULL, 'song_name', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(6, 2, 4, '风格', 'genre', '风格', 1, 2, 'categorical', NULL, 'genre', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(7, 2, 4, '歌手名', 'singer_name', '歌手名', 1, 2, 'categorical', NULL, 'singer_name', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_metric (id, model_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, created_at, created_by, updated_at, updated_by, data_format_type, data_format) VALUES(1, 1, '停留时长', 'stay_hours', '停留时长', 1, 2, 'ATOMIC', '{"expr":"s2_stay_time_statis_stay_hours","measures":[{"agg":"sum","expr":"stay_hours","isCreateMetric":1,"datasourceId":1,"bizName":"s2_stay_time_statis_stay_hours","name":"s2_stay_time_statis_stay_hours"}]}' , '2023-05-24 17:00:00', 'admin', '2023-05-25 00:00:00', 'admin', NULL, NULL );
|
||||
insert into s2_metric (id, model_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, created_at, created_by, updated_at, updated_by, data_format_type, data_format) VALUES(2, 1, '访问次数', 'pv', '访问次数', 1, 0, 'ATOMIC', ' {"expr":"s2_pv_uv_statis_pv","measures":[{"agg":"sum","bizName":"s2_pv_uv_statis_pv","datasourceId":2,"expr":"pv","isCreateMetric":1,"name":"s2_pv_uv_statis_pv"}]}' , '2023-05-24 17:00:00', 'admin', '2023-05-25 00:00:00', 'admin', NULL, NULL );
|
||||
insert into s2_metric (id, model_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, created_at, created_by, updated_at, updated_by, data_format_type, data_format) VALUES(3, 1, '访问人数', 'uv', '访问人数', 1, 0, 'ATOMIC', ' {"expr":"s2_pv_uv_statis_uv","measures":[{"agg":"count_distinct","bizName":"s2_pv_uv_statis_uv","datasourceId":2,"expr":"uv","isCreateMetric":1,"name":"s2_pv_uv_statis_uv"}]}' , '2023-05-24 17:00:00', 'admin', '2023-05-25 00:00:00', 'admin', NULL, NULL );
|
||||
insert into s2_metric (id, model_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, created_at, created_by, updated_at, updated_by, data_format_type, data_format) VALUES(4, 2, '播放量', 'js_play_cnt', '播放量', 1, 2, 'ATOMIC', '{"expr":"music_js_play_cnt","measures":[{"agg":"sum","expr":"js_play_cnt","isCreateMetric":1,"datasourceId":4,"bizName":"music_js_play_cnt","name":"music_js_play_cnt"}]}' , '2023-05-24 17:00:00', 'admin', '2023-05-25 00:00:00', 'admin', NULL, NULL );
|
||||
insert into s2_metric (id, model_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, created_at, created_by, updated_at, updated_by, data_format_type, data_format) VALUES(5, 2, '下载量', 'down_cnt', '下载量', 1, 0, 'ATOMIC', ' {"expr":"music_down_cnt","measures":[{"agg":"sum","bizName":"music_down_cnt","datasourceId":4,"expr":"down_cnt","isCreateMetric":1,"name":"music_down_cnt"}]}' , '2023-05-24 17:00:00', 'admin', '2023-05-25 00:00:00', 'admin', NULL, NULL );
|
||||
insert into s2_metric (id, model_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, created_at, created_by, updated_at, updated_by, data_format_type, data_format) VALUES(6, 2, '收藏量', 'favor_cnt', '收藏量', 1, 0, 'ATOMIC', ' {"expr":"music_favor_cnt","measures":[{"agg":"sum","bizName":"music_favor_cnt","datasourceId":4,"expr":"favor_cnt","isCreateMetric":1,"name":"music_favor_cnt"}]}' , '2023-05-24 17:00:00', 'admin', '2023-05-25 00:00:00', 'admin', NULL, NULL );
|
||||
|
||||
insert into s2_available_date_info(`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` )
|
||||
values (1, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEADD('DAY', -1, CURRENT_DATE()), '[]', '2023-06-01', 'admin', '2023-06-01', 'admin');
|
||||
insert into s2_available_date_info(`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` )
|
||||
@@ -38,11 +12,6 @@ values (2, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEA
|
||||
insert into s2_available_date_info(`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` )
|
||||
values (3, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEADD('DAY', -1, CURRENT_DATE()), '[]', '2023-06-01', 'admin', '2023-06-01', 'admin');
|
||||
|
||||
insert into s2_auth_groups (group_id, config)
|
||||
values (1, '{"modelId":"1","name":"admin-permission","groupId":1,"authRules":[{"metrics":["stay_hours"],"dimensions":["page"]}],"dimensionFilters":[""],"dimensionFilterDescription":"授权admin 页面和停留时长权限","authorizedUsers":["admin"],"authorizedDepartmentIds":[]}');
|
||||
insert into s2_auth_groups (group_id, config)
|
||||
values (2, '{"modelId":"1","name":"tom_sales_permission","groupId":2,"authRules":[{"metrics":["stay_hours"],"dimensions":["page"]}],"dimensionFilters":["department in (''sales'')"],"dimensionFilterDescription":"部门 in [sales]", "authorizedUsers":["tom"],"authorizedDepartmentIds":[]}');
|
||||
|
||||
-- sample data
|
||||
INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000);
|
||||
INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000);
|
||||
@@ -1111,38 +1080,6 @@ INSERT INTO s2_stay_time_statis (imp_date, user_name, stay_hours, page) VALUES (
|
||||
|
||||
|
||||
|
||||
-- benchmark
|
||||
-- CSpider music_1
|
||||
insert into s2_domain (id, `name`, biz_name, parent_id, status, created_at, created_by, updated_at, updated_by, `admin`, admin_org, viewer, view_org) VALUES(2, '音乐', 'music', 0, 1, '2023-05-24 00:00:00', 'admin', '2023-05-24 00:00:00', 'admin', 'admin', '', 'admin,tom,jack', 'admin' );
|
||||
insert into s2_model (id, `name`, biz_name, domain_id, created_at, created_by, updated_at, updated_by, `admin`, admin_org, is_open, viewer, view_org, entity) VALUES(3, '音乐', 'music', 2, '2023-05-24 00:00:00', 'admin', '2023-05-24 00:00:00', 'admin', 'admin', '', 0, 'admin,tom,jack', 'admin','{"entityId": 7, "names": ["音乐"]}' );
|
||||
insert into s2_datasource (id , model_id, `name`, biz_name, description, database_id ,datasource_detail, created_at, created_by, updated_at, updated_by ) VALUES(5, 3, '艺术类型', 'genre', '艺术类型', 1, '{"dimensions":[{"bizName":"most_popular_in","dateFormat":"yyyy-MM-dd","expr":"most_popular_in","isCreateDimension":0,"type":"categorical"}],"identifiers":[{"bizName":"g_name","name":"音乐类型名称","type":"primary"}],"measures":[{"agg":"sum","bizName":"rating","expr":"rating","isCreateMetric":1,"name":"评分"}],"queryType":"sql_query","sqlQuery":"SELECT g_name, rating,most_popular_in FROM genre"}', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource (id , model_id, `name`, biz_name, description, database_id ,datasource_detail, created_at, created_by, updated_at, updated_by ) VALUES(6, 3, '艺术家', 'artist', '艺术家', 1, '{"dimensions":[{"bizName":"country","dateFormat":"yyyy-MM-dd","expr":"country","isCreateDimension":0,"type":"categorical"},{"bizName":"gender","dateFormat":"yyyy-MM-dd","expr":"gender","isCreateDimension":0,"type":"categorical"}],"identifiers":[{"bizName":"artist_name","name":"艺术家名称","type":"primary"},{"bizName":"g_name","name":"音乐类型名称","type":"foreign"}],"measures":[],"queryType":"sql_query","sqlQuery":"SELECT artist_name,country,gender,g_name FROM artist"}', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource (id , model_id, `name`, biz_name, description, database_id ,datasource_detail, created_at, created_by, updated_at, updated_by ) VALUES(7, 3, '文件', 'files', '文件', 1, '{"dimensions":[{"bizName":"duration","dateFormat":"yyyy-MM-dd","expr":"duration","isCreateDimension":0,"type":"categorical"},{"bizName":"formats","dateFormat":"yyyy-MM-dd","expr":"formats","isCreateDimension":0,"type":"categorical"}],"identifiers":[{"bizName":"f_id","name":"歌曲ID","type":"primary"},{"bizName":"artist_name","name":"艺术家名称","type":"foreign"}],"measures":[],"queryType":"sql_query","sqlQuery":"SELECT f_id,artist_name,file_size,duration,formats FROM files"}', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource (id , model_id, `name`, biz_name, description, database_id ,datasource_detail, created_at, created_by, updated_at, updated_by ) VALUES(8, 3, '歌曲', 'song', '歌曲', 1, '{"dimensions":[{"bizName":"imp_date","dateFormat":"yyyy-MM-dd","expr":"imp_date","isCreateDimension":0,"type":"time","typeParams":{"isPrimary":"true","timeGranularity":"day"}},{"bizName":"country","dateFormat":"yyyy-MM-dd","expr":"country","isCreateDimension":1,"name":"国家","type":"categorical"},{"bizName":"languages","dateFormat":"yyyy-MM-dd","expr":"languages","isCreateDimension":1,"name":"语种","type":"categorical"},{"bizName":"releasedate","dateFormat":"yyyy-MM-dd","expr":"releasedate","isCreateDimension":1,"name":"发行时间","type":"categorical"},{"bizName":"rating","dateFormat":"yyyy-MM-dd","expr":"rating","isCreateDimension":1,"name":"评分","type":"categorical"}],"identifiers":[{"bizName":"song_name","name":"歌曲名称","type":"primary"},{"bizName":"f_id","name":"歌曲ID","type":"foreign"},{"bizName":"artist_name","name":"艺术家名称","type":"foreign"},{"bizName":"g_name","name":"音乐类型名称","type":"foreign"}],"measures":[{"agg":"sum","bizName":"resolution","expr":"resolution","isCreateMetric":1,"name":"分辨率"},{"agg":"sum","bizName":"rating","expr":"rating","isCreateMetric":1,"name":"评分"}],"queryType":"sql_query","sqlQuery":"SELECT imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution FROM song "}', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource_rela (id , model_id, `datasource_from`, datasource_to, join_key, created_at, created_by, updated_at, updated_by ) VALUES(4, 3, 5, 6, 'g_name', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource_rela (id , model_id, `datasource_from`, datasource_to, join_key, created_at, created_by, updated_at, updated_by ) VALUES(5, 3, 6, 7, 'artist_name', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource_rela (id , model_id, `datasource_from`, datasource_to, join_key, created_at, created_by, updated_at, updated_by ) VALUES(6, 3, 6, 8, 'artist_name', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource_rela (id , model_id, `datasource_from`, datasource_to, join_key, created_at, created_by, updated_at, updated_by ) VALUES(7, 3, 5, 8, 'g_name', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource_rela (id , model_id, `datasource_from`, datasource_to, join_key, created_at, created_by, updated_at, updated_by ) VALUES(8, 3, 7, 8, 'f_id', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
|
||||
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(8, 3, 5, '音乐类型名称', 'g_name', '音乐类型名称', 1, 0, 'primary', NULL, 'g_name', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(10, 3, 5, '最受欢迎', 'most_popular_in', '最受欢迎', 1, 0, 'categorical', NULL, 'most_popular_in', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(11, 3, 6, '艺术家名称', 'artist_name', '艺术家名称', 1, 0, 'primary', NULL, 'artist_name', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(12, 3, 6, '国籍', 'country', '国籍', 1, 0, 'categorical', NULL, 'country', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(13, 3, 6, '性别', 'gender', '性别', 1, 0, 'categorical', NULL, 'gender', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(15, 3, 7, '歌曲ID', 'f_id', '歌曲ID', 1, 0, 'primary', NULL, 'f_id', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(17, 3, 7, '文件大小', 'file_size', '文件大小', 1, 0, 'categorical', NULL, 'file_size', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(18, 3, 7, '持续时间', 'duration', '持续时间', 1, 0, 'categorical', NULL, 'duration', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(19, 3, 7, '文件格式', 'formats', '文件格式', 1, 0, 'categorical', NULL, 'formats', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(20, 3, 8, '歌曲名称', 'song_name', '歌曲名称', 1, 0, 'primary', NULL, 'song_name', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(22, 3, 8, '国籍', 'country', '国籍', 1, 0, 'categorical', NULL, 'country', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(26, 3, 8, '语种', 'languages', '语种', 1, 0, 'categorical', NULL, 'languages', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(27, 3, 8, '发行时间', 'releasedate', '发行时间', 1, 0, 'categorical', NULL, 'releasedate', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_metric (id, model_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, created_at, created_by, updated_at, updated_by, data_format_type, data_format) VALUES(7, 3, '分辨率', 'resolution', '分辨率', 1, 0, 'ATOMIC', ' {"expr":"resolution","measures":[{"agg":"sum","bizName":"resolution","datasourceId":8,"expr":"resolution","isCreateMetric":1,"name":"resolution"}]}' , '2023-05-24 17:00:00', 'admin', '2023-05-25 00:00:00', 'admin', NULL, NULL );
|
||||
insert into s2_metric (id, model_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, created_at, created_by, updated_at, updated_by, data_format_type, data_format) VALUES(9, 3, '评分', 'rating', '评分', 1, 0, 'ATOMIC', ' {"expr":"rating","measures":[{"agg":"sum","bizName":"rating","datasourceId":8,"expr":"rating","isCreateMetric":1,"name":"rating"}]}' , '2023-05-24 17:00:00', 'admin', '2023-05-25 00:00:00', 'admin', NULL, NULL );
|
||||
|
||||
|
||||
insert into genre(g_name,rating,most_popular_in) VALUES ('tagore',8,'孟加拉国');
|
||||
insert into genre(g_name,rating,most_popular_in) VALUES ('nazrul',7,'孟加拉国');
|
||||
insert into genre(g_name,rating,most_popular_in) VALUES ('民间',9,'锡尔赫特、吉大港、库斯蒂亚');
|
||||
|
||||
@@ -210,7 +210,7 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
ChatConfigEditReqReq extendEditCmd = new ChatConfigEditReqReq();
|
||||
BeanUtils.copyProperties(chatConfig, extendEditCmd);
|
||||
// add blacklist
|
||||
List<Long> blackMetrics = Arrays.asList(3L);
|
||||
List<Long> blackMetrics = Arrays.asList(2L);
|
||||
extendEditCmd.getChatAggConfig().getVisibility().setBlackMetricIdList(blackMetrics);
|
||||
configService.editConfig(extendEditCmd, User.getFakeUser());
|
||||
|
||||
|
||||
@@ -4,32 +4,6 @@ insert into s2_user (id, `name`, password, display_name, email) values (2, 'jack
|
||||
insert into s2_user (id, `name`, password, display_name, email) values (3, 'tom','123456','tom','tom@xx.com');
|
||||
insert into s2_user (id, `name`, password, display_name, email) values (4, 'lucy','123456','lucy','lucy@xx.com');
|
||||
|
||||
-- sample models
|
||||
insert into s2_domain (id, `name`, biz_name, parent_id, status, created_at, created_by, updated_at, updated_by, `admin`, admin_org, viewer, view_org) VALUES(1, '超音数', 'supersonic', 0, 1, '2023-05-24 00:00:00', 'admin', '2023-05-24 00:00:00', 'admin', 'admin', '', 'admin,tom,jack', 'admin' );
|
||||
insert into s2_model (id, `name`, biz_name, domain_id, created_at, created_by, updated_at, updated_by, `admin`, admin_org, is_open, viewer, view_org, entity) VALUES(1, '超音数', 'supersonic', 1, '2023-05-24 00:00:00', 'admin', '2023-05-24 00:00:00', 'admin', 'admin', '', 0, 'admin,tom,jack', 'admin','' );
|
||||
insert into s2_model (id, `name`, biz_name, domain_id, created_at, created_by, updated_at, updated_by, `admin`, admin_org, is_open, viewer, view_org, entity) VALUES(2, '艺人库', 'singer', 1, '2023-05-24 00:00:00', 'admin', '2023-05-24 00:00:00', 'admin', 'admin', '', 0, 'admin,tom,jack', 'admin','{"entityId": 7, "names": ["歌手", "艺人"]}' );
|
||||
insert into s2_database (id, `name`, description, `type` ,config ,created_at ,created_by ,updated_at ,updated_by, `admin`) VALUES(1, 'H2数据实例', '', 'h2', '{"password":"semantic","url":"jdbc:h2:mem:semantic;DATABASE_TO_UPPER=false","userName":"root"}', '2023-05-24 00:00:00', 'admin', '2023-05-24 00:00:00', 'admin', 'admin');
|
||||
insert into s2_datasource (id , model_id, `name`, biz_name, description, database_id ,datasource_detail, created_at, created_by, updated_at, updated_by ) VALUES(1, 1, '停留时长统计', 's2_stay_time_statis', '停留时长统计', 1, '{"dimensions":[{"bizName":"imp_date","dateFormat":"yyyy-MM-dd","expr":"imp_date","isCreateDimension":0,"type":"time","typeParams":{"isPrimary":"true","timeGranularity":"day"}},{"bizName":"page","dateFormat":"yyyy-MM-dd","expr":"page","isCreateDimension":0,"type":"categorical"}],"identifiers":[{"bizName":"user_name","name":"用户名","type":"primary"}],"measures":[{"agg":"sum","bizName":"s2_stay_time_statis_stay_hours","expr":"stay_hours","isCreateMetric":1,"name":"停留时长"}],"queryType":"sql_query","sqlQuery":"SELECT imp_date, page,user_name,stay_hours FROM s2_stay_time_statis"}', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource (id , model_id, `name`, biz_name, description, database_id ,datasource_detail, created_at, created_by, updated_at, updated_by ) VALUES(2, 1, 'PVUV统计', 's2_pv_uv_statis', 'PVUV统计', 1, '{"dimensions":[{"bizName":"imp_date","dateFormat":"yyyy-MM-dd","expr":"imp_date","isCreateDimension":0,"type":"time","typeParams":{"isPrimary":"true","timeGranularity":"day"}},{"bizName":"page","dateFormat":"yyyy-MM-dd","expr":"page","isCreateDimension":0,"type":"categorical"}],"identifiers":[{"bizName":"user_name","name":"用户名","type":"primary"}],"measures":[{"agg":"sum","bizName":"s2_pv_uv_statis_pv","expr":"pv","isCreateMetric":1,"name":"访问次数"},{"agg":"count_distinct","bizName":"s2_pv_uv_statis_uv","expr":"uv","isCreateMetric":1,"name":"访问人数"}],"queryType":"sql_query","sqlQuery":"SELECT imp_date, user_name,page,1 as pv, user_name as uv FROM s2_pv_uv_statis"}', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource (id , model_id, `name`, biz_name, description, database_id ,datasource_detail, created_at, created_by, updated_at, updated_by ) VALUES(3, 1, '用户部门', 'user_department', '用户部门', 1, '{"dimensions":[{"bizName":"department","dateFormat":"yyyy-MM-dd","expr":"department","isCreateDimension":1,"name":"部门","type":"categorical"}],"identifiers":[{"bizName":"user_name","name":"用户名","type":"primary"}],"measures":[],"queryType":"sql_query","sqlQuery":"SELECT user_name,department FROM s2_user_department"}', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource (id , model_id, `name`, biz_name, description, database_id ,datasource_detail, created_at, created_by, updated_at, updated_by ) VALUES(4, 2, '艺人库', 'singer', '艺人库', 1, '{"dimensions":[{"bizName":"imp_date","dateFormat":"yyyy-MM-dd","expr":"imp_date","isCreateDimension":0,"type":"time","typeParams":{"isPrimary":"true","timeGranularity":"day"}},{"bizName":"act_area","dateFormat":"yyyy-MM-dd","expr":"act_area","isCreateDimension":1,"name":"活跃区域","type":"categorical"},{"bizName":"song_name","dateFormat":"yyyy-MM-dd","expr":"song_name","isCreateDimension":1,"name":"代表作","type":"categorical"},{"bizName":"genre","dateFormat":"yyyy-MM-dd","expr":"genre","isCreateDimension":1,"name":"风格","type":"categorical"}],"identifiers":[{"bizName":"singer_name","name":"歌手名","type":"primary"}],"measures":[{"agg":"sum","bizName":"music_down_cnt","expr":"down_cnt","isCreateMetric":1,"name":"下载量"},{"agg":"sum","bizName":"music_js_play_cnt","expr":"js_play_cnt","isCreateMetric":1,"name":"播放量"},{"agg":"sum","bizName":"music_favor_cnt","expr":"favor_cnt","isCreateMetric":1,"name":"收藏量"}],"queryType":"sql_query","sqlQuery":"SELECT imp_date,singer_name,act_area,song_name,genre,js_play_cnt,down_cnt,favor_cnt FROM singer "}', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource_rela (id , model_id, `datasource_from`, datasource_to, join_key, created_at, created_by, updated_at, updated_by ) VALUES(1, 1, 1, 2, 'user_name', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource_rela (id , model_id, `datasource_from`, datasource_to, join_key, created_at, created_by, updated_at, updated_by ) VALUES(2, 1, 1, 3, 'user_name', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_datasource_rela (id , model_id, `datasource_from`, datasource_to, join_key, created_at, created_by, updated_at, updated_by ) VALUES(3, 1, 2, 3, 'user_name', '2023-05-25 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type, dim_value_maps) VALUES(1, 1, 3, '部门', 'department', '部门', 1, 0, 'categorical', NULL, 'department', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY', '[{"alias":["人力资源","人力"],"bizName":"人力资源","techName":"HR"},{"alias":["营销","销售"],"bizName":"营销部门","techName":"sales"}]');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(2, 1, 1, '用户名', 'user_name', '用户名', 1, 0, 'primary', NULL, 'user_name', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(3, 1, 2, '页面', 'page', '页面', 1, 2, 'categorical', NULL, 'page', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(4, 2, 4, '活跃区域', 'act_area', '活跃区域', 1, 2, 'categorical', NULL, 'act_area', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(5, 2, 4, '代表作', 'song_name', '代表作', 1, 2, 'categorical', NULL, 'song_name', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(6, 2, 4, '风格', 'genre', '风格', 1, 2, 'categorical', NULL, 'genre', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_dimension (id , model_id, datasource_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, expr, created_at, created_by, updated_at, updated_by, semantic_type) VALUES(7, 2, 4, '歌手名', 'singer_name', '歌手名', 1, 2, 'categorical', NULL, 'singer_name', '2023-05-24 00:00:00', 'admin', '2023-05-25 00:00:00', 'admin', 'CATEGORY');
|
||||
insert into s2_metric (id, model_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, created_at, created_by, updated_at, updated_by, data_format_type, data_format) VALUES(1, 1, '停留时长', 'stay_hours', '停留时长', 1, 2, 'ATOMIC', '{"expr":"s2_stay_time_statis_stay_hours","measures":[{"agg":"sum","expr":"stay_hours","isCreateMetric":1,"datasourceId":1,"bizName":"s2_stay_time_statis_stay_hours","name":"s2_stay_time_statis_stay_hours"}]}' , '2023-05-24 17:00:00', 'admin', '2023-05-25 00:00:00', 'admin', NULL, NULL );
|
||||
insert into s2_metric (id, model_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, created_at, created_by, updated_at, updated_by, data_format_type, data_format) VALUES(2, 1, '访问次数', 'pv', '访问次数', 1, 0, 'ATOMIC', ' {"expr":"s2_pv_uv_statis_pv","measures":[{"agg":"sum","bizName":"s2_pv_uv_statis_pv","datasourceId":2,"expr":"pv","isCreateMetric":1,"name":"s2_pv_uv_statis_pv"}]}' , '2023-05-24 17:00:00', 'admin', '2023-05-25 00:00:00', 'admin', NULL, NULL );
|
||||
insert into s2_metric (id, model_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, created_at, created_by, updated_at, updated_by, data_format_type, data_format) VALUES(3, 1, '访问人数', 'uv', '访问人数', 1, 0, 'ATOMIC', ' {"expr":"s2_pv_uv_statis_uv","measures":[{"agg":"count_distinct","bizName":"s2_pv_uv_statis_uv","datasourceId":2,"expr":"uv","isCreateMetric":1,"name":"s2_pv_uv_statis_uv"}]}' , '2023-05-24 17:00:00', 'admin', '2023-05-25 00:00:00', 'admin', NULL, NULL );
|
||||
insert into s2_metric (id, model_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, created_at, created_by, updated_at, updated_by, data_format_type, data_format) VALUES(4, 2, '播放量', 'js_play_cnt', '播放量', 1, 2, 'ATOMIC', '{"expr":"music_js_play_cnt","measures":[{"agg":"sum","expr":"js_play_cnt","isCreateMetric":1,"datasourceId":4,"bizName":"music_js_play_cnt","name":"music_js_play_cnt"}]}' , '2023-05-24 17:00:00', 'admin', '2023-05-25 00:00:00', 'admin', NULL, NULL );
|
||||
insert into s2_metric (id, model_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, created_at, created_by, updated_at, updated_by, data_format_type, data_format) VALUES(5, 2, '下载量', 'down_cnt', '下载量', 1, 0, 'ATOMIC', ' {"expr":"music_down_cnt","measures":[{"agg":"sum","bizName":"music_down_cnt","datasourceId":4,"expr":"down_cnt","isCreateMetric":1,"name":"music_down_cnt"}]}' , '2023-05-24 17:00:00', 'admin', '2023-05-25 00:00:00', 'admin', NULL, NULL );
|
||||
insert into s2_metric (id, model_id, `name`, biz_name, description, status, sensitive_level, `type`, type_params, created_at, created_by, updated_at, updated_by, data_format_type, data_format) VALUES(6, 2, '收藏量', 'favor_cnt', '收藏量', 1, 0, 'ATOMIC', ' {"expr":"music_favor_cnt","measures":[{"agg":"sum","bizName":"music_favor_cnt","datasourceId":4,"expr":"favor_cnt","isCreateMetric":1,"name":"music_favor_cnt"}]}' , '2023-05-24 17:00:00', 'admin', '2023-05-25 00:00:00', 'admin', NULL, NULL );
|
||||
|
||||
insert into s2_available_date_info(`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` )
|
||||
values (1, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEADD('DAY', -1, CURRENT_DATE()), '[]', '2023-06-01', 'admin', '2023-06-01', 'admin');
|
||||
insert into s2_available_date_info(`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` )
|
||||
@@ -37,11 +11,6 @@ values (2, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEA
|
||||
insert into s2_available_date_info(`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` )
|
||||
values (3, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEADD('DAY', -1, CURRENT_DATE()), '[]', '2023-06-01', 'admin', '2023-06-01', 'admin');
|
||||
|
||||
insert into s2_auth_groups (group_id, config)
|
||||
values (1, '{"modelId":"1","name":"admin-permission","groupId":1,"authRules":[{"metrics":["stay_hours"],"dimensions":["page"]}],"dimensionFilters":[""],"dimensionFilterDescription":"授权admin 页面和停留时长权限","authorizedUsers":["admin"],"authorizedDepartmentIds":[]}');
|
||||
insert into s2_auth_groups (group_id, config)
|
||||
values (2, '{"modelId":"1","name":"tom_sales_permission","groupId":2,"authRules":[{"metrics":["stay_hours"],"dimensions":["page"]}],"dimensionFilters":["department in (''sales'')"],"dimensionFilterDescription":"开通 tom sales部门权限", "authorizedUsers":["tom"],"authorizedDepartmentIds":[]}');
|
||||
|
||||
-- sample data
|
||||
INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '周杰伦', '中国','青花瓷','流行',1000000,1000000,1000000);
|
||||
INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '周杰伦', '中国','青花瓷','流行',1000000,1000000,1000000);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.tencent.supersonic.semantic.api.model.enums;
|
||||
|
||||
public enum IdentifyTypeEnum {
|
||||
|
||||
primary,
|
||||
|
||||
foreign,
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.tencent.supersonic.semantic.api.model.enums;
|
||||
|
||||
public enum SemanticTypeEnum {
|
||||
|
||||
CATEGORY,
|
||||
ID,
|
||||
DATE,
|
||||
NUMBER
|
||||
|
||||
}
|
||||
@@ -25,6 +25,13 @@ public class Dim {
|
||||
|
||||
private String bizName;
|
||||
|
||||
public Dim(String name, String bizName, String type, Integer isCreateDimension) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.isCreateDimension = isCreateDimension;
|
||||
this.bizName = bizName;
|
||||
}
|
||||
|
||||
public static Dim getDefault() {
|
||||
return new Dim("日期", "time", "2023-05-28",
|
||||
Constants.DAY_FORMAT,
|
||||
|
||||
@@ -10,8 +10,8 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class DimensionTimeTypeParams {
|
||||
|
||||
private String isPrimary;
|
||||
private String isPrimary = "true";
|
||||
|
||||
private String timeGranularity;
|
||||
private String timeGranularity = "day";
|
||||
|
||||
}
|
||||
|
||||
@@ -28,5 +28,10 @@ public class Measure {
|
||||
|
||||
private Long datasourceId;
|
||||
|
||||
|
||||
public Measure(String name, String bizName, String agg, Integer isCreateMetric) {
|
||||
this.name = name;
|
||||
this.agg = agg;
|
||||
this.isCreateMetric = isCreateMetric;
|
||||
this.bizName = bizName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,13 @@ public class H2Adaptor extends EngineAdaptor {
|
||||
|
||||
@Override
|
||||
public String getColumnMetaQueryTpl() {
|
||||
return "SELECT COLUMN_NAME AS name, DATA_TYPE AS dataType\n"
|
||||
+ "FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA ='%s' AND TABLE_NAME = '%s'";
|
||||
return "SELECT COLUMN_NAME AS name, "
|
||||
+ " case DATA_TYPE"
|
||||
+ " when '12' then 'varchar'"
|
||||
+ " when '-5' then 'integer'"
|
||||
+ " when '8' then 'double'"
|
||||
+ " end AS dataType"
|
||||
+ " FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA ='%s' AND TABLE_NAME = '%s'";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user