mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 20:25:12 +00:00
(improvement)(Headless)(Chat) Change View to DataSet (#782)
* (improvement)(Headless)(Chat) Change view to dataSet --------- Co-authored-by: jolunoluo <jolunoluo@tencent.com>
This commit is contained in:
@@ -4,8 +4,8 @@ import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ViewDetail {
|
||||
public class DataSetDetail {
|
||||
|
||||
private List<ViewModelConfig> viewModelConfigs;
|
||||
private List<DataSetModelConfig> dataSetModelConfigs;
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import java.util.List;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ViewModelConfig {
|
||||
public class DataSetModelConfig {
|
||||
|
||||
private Long id;
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ViewModelConfig {
|
||||
|
||||
private List<Long> dimensions = Lists.newArrayList();
|
||||
|
||||
public ViewModelConfig(Long id, List<Long> dimensions, List<Long> metrics) {
|
||||
public DataSetModelConfig(Long id, List<Long> dimensions, List<Long> metrics) {
|
||||
this.id = id;
|
||||
this.metrics = metrics;
|
||||
this.dimensions = dimensions;
|
||||
@@ -25,8 +25,8 @@ public class QueryParam {
|
||||
private QueryType queryType;
|
||||
private String s2SQL;
|
||||
private String correctS2SQL;
|
||||
private Long viewId;
|
||||
private String viewName;
|
||||
private Long dataSetId;
|
||||
private String dataSetName;
|
||||
private Set<Long> modelIds = new HashSet<>();
|
||||
private List<Param> params = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public class QueryStat {
|
||||
private String traceId;
|
||||
private Long modelId;
|
||||
|
||||
private Long viewId;
|
||||
private Long dataSetId;
|
||||
private String user;
|
||||
private String createdAt;
|
||||
/**
|
||||
@@ -93,8 +93,8 @@ public class QueryStat {
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setViewId(Long viewId) {
|
||||
this.viewId = viewId;
|
||||
public QueryStat setDataSetId(Long dataSetId) {
|
||||
this.dataSetId = dataSetId;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
@NoArgsConstructor
|
||||
public class SchemaElement implements Serializable {
|
||||
|
||||
private Long view;
|
||||
private Long dataSet;
|
||||
private Long model;
|
||||
private Long id;
|
||||
private String name;
|
||||
@@ -41,7 +41,7 @@ public class SchemaElement implements Serializable {
|
||||
return false;
|
||||
}
|
||||
SchemaElement schemaElement = (SchemaElement) o;
|
||||
return Objects.equal(view, schemaElement.view) && Objects.equal(id,
|
||||
return Objects.equal(dataSet, schemaElement.dataSet) && Objects.equal(id,
|
||||
schemaElement.id) && Objects.equal(name, schemaElement.name)
|
||||
&& Objects.equal(bizName, schemaElement.bizName)
|
||||
&& Objects.equal(type, schemaElement.type);
|
||||
@@ -49,7 +49,7 @@ public class SchemaElement implements Serializable {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(view, id, name, bizName, type);
|
||||
return Objects.hashCode(dataSet, id, name, bizName, type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.tencent.supersonic.headless.api.pojo;
|
||||
|
||||
public enum SchemaElementType {
|
||||
VIEW,
|
||||
DATASET,
|
||||
METRIC,
|
||||
DIMENSION,
|
||||
VALUE,
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.tencent.supersonic.headless.api.pojo.enums;
|
||||
|
||||
/**
|
||||
* model datasource define type:
|
||||
* sql_query : view sql begin as select
|
||||
* sql_query : dataSet sql begin as select
|
||||
* table_query: dbName.tableName
|
||||
*/
|
||||
public enum ModelDefineType {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.tencent.supersonic.headless.api.pojo.request;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class DataSetFilterReq {
|
||||
|
||||
protected boolean defaultAll = true;
|
||||
|
||||
protected List<Long> dataSetIds = Lists.newArrayList();
|
||||
|
||||
public DataSetFilterReq(Long dataSetId) {
|
||||
addDataSet(dataSetId);
|
||||
}
|
||||
|
||||
public List<Long> getDataSetIds() {
|
||||
if (CollectionUtils.isEmpty(dataSetIds) && !defaultAll) {
|
||||
return Lists.newArrayList(-1L);
|
||||
}
|
||||
return dataSetIds;
|
||||
}
|
||||
|
||||
public void addDataSet(Long dataSetId) {
|
||||
dataSetIds.add(dataSetId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,17 +2,17 @@ package com.tencent.supersonic.headless.api.pojo.request;
|
||||
|
||||
import com.tencent.supersonic.headless.api.pojo.QueryConfig;
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaItem;
|
||||
import com.tencent.supersonic.headless.api.pojo.ViewDetail;
|
||||
import com.tencent.supersonic.headless.api.pojo.DataSetDetail;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ViewReq extends SchemaItem {
|
||||
public class DataSetReq extends SchemaItem {
|
||||
|
||||
private Long domainId;
|
||||
|
||||
private ViewDetail viewDetail;
|
||||
private DataSetDetail dataSetDetail;
|
||||
|
||||
private String alias;
|
||||
|
||||
@@ -7,17 +7,18 @@ import com.tencent.supersonic.common.pojo.Order;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class QueryViewReq {
|
||||
public class QueryDataSetReq {
|
||||
|
||||
private Long viewId;
|
||||
private String viewName;
|
||||
private Long dataSetId;
|
||||
private String dataSetName;
|
||||
private String sql;
|
||||
private boolean needAuth = true;
|
||||
private List<Param> params = new ArrayList<>();
|
||||
@@ -27,7 +27,7 @@ public class QueryMultiStructReq extends SemanticQueryReq {
|
||||
if (CollectionUtils.isEmpty(this.getQueryStructReqs())) {
|
||||
return null;
|
||||
}
|
||||
return this.getQueryStructReqs().get(0).getViewId();
|
||||
return this.getQueryStructReqs().get(0).getDataSetId();
|
||||
}
|
||||
|
||||
public Cache getCacheInfo() {
|
||||
|
||||
@@ -12,8 +12,8 @@ public class QuerySqlReq extends SemanticQueryReq {
|
||||
@Override
|
||||
public String toCustomizedString() {
|
||||
StringBuilder stringBuilder = new StringBuilder("{");
|
||||
stringBuilder.append("\"viewId\":")
|
||||
.append(viewId);
|
||||
stringBuilder.append("\"dataSetId\":")
|
||||
.append(dataSetId);
|
||||
stringBuilder.append("\"modelIds\":")
|
||||
.append(modelIds);
|
||||
stringBuilder.append(",\"params\":")
|
||||
|
||||
@@ -94,8 +94,8 @@ public class QueryStructReq extends SemanticQueryReq {
|
||||
|
||||
public String toCustomizedString() {
|
||||
StringBuilder stringBuilder = new StringBuilder("{");
|
||||
stringBuilder.append("\"viewId\":")
|
||||
.append(viewId);
|
||||
stringBuilder.append("\"dataSetId\":")
|
||||
.append(dataSetId);
|
||||
stringBuilder.append("\"modelIds\":")
|
||||
.append(modelIds);
|
||||
stringBuilder.append(",\"groups\":")
|
||||
@@ -127,8 +127,8 @@ public class QueryStructReq extends SemanticQueryReq {
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"viewId\":")
|
||||
.append(viewId);
|
||||
sb.append("\"dataSetId\":")
|
||||
.append(dataSetId);
|
||||
sb.append("\"modelIds\":")
|
||||
.append(modelIds);
|
||||
sb.append(",\"groups\":")
|
||||
@@ -172,7 +172,7 @@ public class QueryStructReq extends SemanticQueryReq {
|
||||
|
||||
QuerySqlReq result = new QuerySqlReq();
|
||||
result.setSql(sql);
|
||||
result.setViewId(this.getViewId());
|
||||
result.setDataSetId(this.getDataSetId());
|
||||
result.setModelIds(this.getModelIdSet());
|
||||
result.setParams(new ArrayList<>());
|
||||
return result;
|
||||
@@ -276,11 +276,11 @@ public class QueryStructReq extends SemanticQueryReq {
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
if (StringUtils.isNotBlank(viewName)) {
|
||||
return viewName;
|
||||
if (StringUtils.isNotBlank(dataSetName)) {
|
||||
return dataSetName;
|
||||
}
|
||||
if (viewId != null) {
|
||||
return Constants.TABLE_PREFIX + viewId;
|
||||
if (dataSetId != null) {
|
||||
return Constants.TABLE_PREFIX + dataSetId;
|
||||
}
|
||||
return Constants.TABLE_PREFIX + StringUtils.join(modelIds, "_");
|
||||
}
|
||||
|
||||
@@ -5,14 +5,15 @@ import com.tencent.supersonic.common.pojo.Aggregator;
|
||||
import com.tencent.supersonic.common.pojo.DateConf;
|
||||
import com.tencent.supersonic.common.pojo.Filter;
|
||||
import com.tencent.supersonic.common.pojo.Order;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
@Slf4j
|
||||
@ToString
|
||||
@@ -32,8 +33,8 @@ public class QueryTagReq extends SemanticQueryReq {
|
||||
@Override
|
||||
public String toCustomizedString() {
|
||||
StringBuilder stringBuilder = new StringBuilder("{");
|
||||
stringBuilder.append("\"viewId\":")
|
||||
.append(viewId);
|
||||
stringBuilder.append("\"dataSetId\":")
|
||||
.append(dataSetId);
|
||||
stringBuilder.append("\"modelIds\":")
|
||||
.append(modelIds);
|
||||
stringBuilder.append(",\"groups\":")
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.List;
|
||||
@Data
|
||||
public class SchemaFilterReq {
|
||||
|
||||
private Long viewId;
|
||||
private Long dataSetId;
|
||||
|
||||
private List<Long> modelIds = Lists.newArrayList();
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ public abstract class SemanticQueryReq {
|
||||
|
||||
protected boolean needAuth = true;
|
||||
|
||||
protected Long viewId;
|
||||
protected Long dataSetId;
|
||||
|
||||
protected String viewName;
|
||||
protected String dataSetName;
|
||||
|
||||
protected Set<Long> modelIds = new HashSet<>();
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.pojo.request;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class ViewFilterReq {
|
||||
|
||||
protected boolean defaultAll = true;
|
||||
|
||||
protected List<Long> viewIds = Lists.newArrayList();
|
||||
|
||||
public ViewFilterReq(Long viewId) {
|
||||
addView(viewId);
|
||||
}
|
||||
|
||||
public List<Long> getViewIds() {
|
||||
if (CollectionUtils.isEmpty(viewIds) && !defaultAll) {
|
||||
return Lists.newArrayList(-1L);
|
||||
}
|
||||
return viewIds;
|
||||
}
|
||||
|
||||
public void addView(Long viewId) {
|
||||
viewIds.add(viewId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,8 @@ package com.tencent.supersonic.headless.api.pojo.response;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.api.pojo.QueryConfig;
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaItem;
|
||||
import com.tencent.supersonic.headless.api.pojo.ViewDetail;
|
||||
import com.tencent.supersonic.headless.api.pojo.ViewModelConfig;
|
||||
import com.tencent.supersonic.headless.api.pojo.DataSetDetail;
|
||||
import com.tencent.supersonic.headless.api.pojo.DataSetModelConfig;
|
||||
import lombok.Data;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@@ -14,11 +14,11 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
public class ViewResp extends SchemaItem {
|
||||
public class DataSetResp extends SchemaItem {
|
||||
|
||||
private Long domainId;
|
||||
|
||||
private ViewDetail viewDetail;
|
||||
private DataSetDetail dataSetDetail;
|
||||
|
||||
private String alias;
|
||||
|
||||
@@ -31,31 +31,31 @@ public class ViewResp extends SchemaItem {
|
||||
private QueryConfig queryConfig;
|
||||
|
||||
public List<Long> getAllMetrics() {
|
||||
return getViewModelConfigs().stream().map(ViewModelConfig::getMetrics)
|
||||
return getDataSetModelConfigs().stream().map(DataSetModelConfig::getMetrics)
|
||||
.flatMap(Collection::stream).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<Long> getAllDimensions() {
|
||||
return getViewModelConfigs().stream().map(ViewModelConfig::getDimensions)
|
||||
return getDataSetModelConfigs().stream().map(DataSetModelConfig::getDimensions)
|
||||
.flatMap(Collection::stream).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<Long> getAllModels() {
|
||||
return getViewModelConfigs().stream().map(ViewModelConfig::getId)
|
||||
return getDataSetModelConfigs().stream().map(DataSetModelConfig::getId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<Long> getAllIncludeAllModels() {
|
||||
return getViewModelConfigs().stream().filter(ViewModelConfig::isIncludesAll)
|
||||
.map(ViewModelConfig::getId)
|
||||
return getDataSetModelConfigs().stream().filter(DataSetModelConfig::isIncludesAll)
|
||||
.map(DataSetModelConfig::getId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<ViewModelConfig> getViewModelConfigs() {
|
||||
if (viewDetail == null || CollectionUtils.isEmpty(viewDetail.getViewModelConfigs())) {
|
||||
private List<DataSetModelConfig> getDataSetModelConfigs() {
|
||||
if (dataSetDetail == null || CollectionUtils.isEmpty(dataSetDetail.getDataSetModelConfigs())) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return viewDetail.getViewModelConfigs();
|
||||
return dataSetDetail.getDataSetModelConfigs();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ViewSchemaResp extends ViewResp {
|
||||
public class DataSetSchemaResp extends DataSetResp {
|
||||
|
||||
private List<MetricSchemaResp> metrics = Lists.newArrayList();
|
||||
private List<DimSchemaResp> dimensions = Lists.newArrayList();
|
||||
@@ -17,7 +17,7 @@ import static com.tencent.supersonic.common.pojo.Constants.UNDERLINE;
|
||||
@NoArgsConstructor
|
||||
public class SemanticSchemaResp {
|
||||
|
||||
private Long viewId;
|
||||
private Long dataSetId;
|
||||
private List<Long> modelIds;
|
||||
private SchemaType schemaType;
|
||||
private List<MetricSchemaResp> metrics = Lists.newArrayList();
|
||||
@@ -25,14 +25,14 @@ public class SemanticSchemaResp {
|
||||
private List<TagResp> tags = Lists.newArrayList();
|
||||
private List<ModelRela> modelRelas = Lists.newArrayList();
|
||||
private List<ModelResp> modelResps = Lists.newArrayList();
|
||||
private ViewResp viewResp;
|
||||
private DataSetResp dataSetResp;
|
||||
private DatabaseResp databaseResp;
|
||||
|
||||
public String getSchemaKey() {
|
||||
if (viewId == null) {
|
||||
if (dataSetId == null) {
|
||||
return String.format("%s_%s", schemaType, StringUtils.join(modelIds, UNDERLINE));
|
||||
}
|
||||
return String.format("%s_%s", schemaType, viewId);
|
||||
return String.format("%s_%s", schemaType, dataSetId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user