mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-13 04:57:28 +00:00
Merge pull request #759 from lexluo09/master
(improvement)(project) merge master to dev-0.9
This commit is contained in:
@@ -19,13 +19,15 @@ public class ModelDetail {
|
||||
|
||||
private String tableQuery;
|
||||
|
||||
private List<Identify> identifiers;
|
||||
private List<Identify> identifiers = Lists.newArrayList();
|
||||
|
||||
private List<Dim> dimensions;
|
||||
private List<Dim> dimensions = Lists.newArrayList();
|
||||
|
||||
private List<Measure> measures;
|
||||
private List<Measure> measures = Lists.newArrayList();
|
||||
|
||||
private List<Field> fields;
|
||||
private List<Field> fields = Lists.newArrayList();
|
||||
|
||||
private List<SqlVariable> sqlVariables = Lists.newArrayList();
|
||||
|
||||
public String getSqlQuery() {
|
||||
if (StringUtils.isNotBlank(sqlQuery) && sqlQuery.endsWith(";")) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.tencent.supersonic.headless.api.pojo;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class Param {
|
||||
@@ -10,7 +11,7 @@ public class Param {
|
||||
@NotBlank(message = "Invald parameter name")
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "Invalid parameter value")
|
||||
@NotNull(message = "Invalid parameter value")
|
||||
private String value;
|
||||
|
||||
public Param() {
|
||||
@@ -21,14 +22,4 @@ public class Param {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"name\":\"")
|
||||
.append(name).append('\"');
|
||||
sb.append(",\"value\":\"")
|
||||
.append(value).append('\"');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.tencent.supersonic.headless.api.pojo;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -19,6 +18,7 @@ import java.util.List;
|
||||
public class SchemaElement implements Serializable {
|
||||
|
||||
private Long view;
|
||||
private Long model;
|
||||
private Long id;
|
||||
private String name;
|
||||
private String bizName;
|
||||
@@ -52,7 +52,4 @@ public class SchemaElement implements Serializable {
|
||||
return Objects.hashCode(view, id, name, bizName, type);
|
||||
}
|
||||
|
||||
public List<String> getModelNames() {
|
||||
return Lists.newArrayList(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.tencent.supersonic.headless.api.pojo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.api.pojo.enums.VariableValueType;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SqlVariable {
|
||||
private String name;
|
||||
private VariableValueType valueType;
|
||||
private List<Object> defaultValues = Lists.newArrayList();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.tencent.supersonic.headless.api.pojo.enums;
|
||||
|
||||
public enum VariableValueType {
|
||||
STRING,
|
||||
NUMBER,
|
||||
EXPR
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.tencent.supersonic.headless.api.pojo.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.DateConf;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
@@ -18,4 +19,8 @@ public class QueryMetricReq {
|
||||
|
||||
private List<String> dimensionNames;
|
||||
|
||||
private DateConf dateInfo = new DateConf();
|
||||
|
||||
private Long limit = 2000L;
|
||||
|
||||
}
|
||||
@@ -44,6 +44,7 @@ import java.util.stream.Collectors;
|
||||
@Data
|
||||
@Slf4j
|
||||
public class QueryStructReq extends SemanticQueryReq {
|
||||
|
||||
private List<String> groups = new ArrayList<>();
|
||||
private List<Aggregator> aggregators = new ArrayList<>();
|
||||
private List<Order> orders = new ArrayList<>();
|
||||
@@ -151,28 +152,27 @@ public class QueryStructReq extends SemanticQueryReq {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public QuerySqlReq convert(QueryStructReq queryStructReq) {
|
||||
return convert(queryStructReq, false);
|
||||
public QuerySqlReq convert() {
|
||||
return convert(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert queryStructReq to QueryS2SQLReq
|
||||
*
|
||||
* @param queryStructReq
|
||||
* @return
|
||||
*/
|
||||
public QuerySqlReq convert(QueryStructReq queryStructReq, boolean isBizName) {
|
||||
public QuerySqlReq convert(boolean isBizName) {
|
||||
String sql = null;
|
||||
try {
|
||||
sql = buildSql(queryStructReq, isBizName);
|
||||
sql = buildSql(this, isBizName);
|
||||
} catch (Exception e) {
|
||||
log.error("buildSql error", e);
|
||||
}
|
||||
|
||||
QuerySqlReq result = new QuerySqlReq();
|
||||
result.setSql(sql);
|
||||
result.setViewId(queryStructReq.getViewId());
|
||||
result.setModelIds(queryStructReq.getModelIdSet());
|
||||
result.setViewId(this.getViewId());
|
||||
result.setModelIds(this.getModelIdSet());
|
||||
result.setParams(new ArrayList<>());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ public class ViewReq extends SchemaItem {
|
||||
|
||||
private String alias;
|
||||
|
||||
private String filterSql;
|
||||
|
||||
private QueryConfig queryConfig;
|
||||
|
||||
private List<String> admins;
|
||||
|
||||
@@ -30,6 +30,8 @@ public class MetricResp extends SchemaItem {
|
||||
|
||||
private Long domainId;
|
||||
|
||||
private String modelBizName;
|
||||
|
||||
private String modelName;
|
||||
|
||||
//ATOMIC DERIVED
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.tencent.supersonic.headless.api.pojo.response;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.tencent.supersonic.common.pojo.ModelRela;
|
||||
import com.tencent.supersonic.headless.api.pojo.Identify;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@@ -17,18 +19,17 @@ public class ModelSchemaResp extends ModelResp {
|
||||
private List<DimSchemaResp> dimensions;
|
||||
private List<ModelRela> modelRelas;
|
||||
|
||||
public DimSchemaResp getPrimaryKey() {
|
||||
Identify identify = getPrimaryIdentify();
|
||||
if (identify == null) {
|
||||
return null;
|
||||
public Set<Long> getModelClusterSet() {
|
||||
if (CollectionUtils.isEmpty(this.modelRelas)) {
|
||||
return Sets.newHashSet();
|
||||
} else {
|
||||
Set<Long> modelClusterSet = new HashSet();
|
||||
this.modelRelas.forEach((modelRela) -> {
|
||||
modelClusterSet.add(modelRela.getToModelId());
|
||||
modelClusterSet.add(modelRela.getFromModelId());
|
||||
});
|
||||
return modelClusterSet;
|
||||
}
|
||||
for (DimSchemaResp dimension : dimensions) {
|
||||
if (identify.getBizName().equals(dimension.getBizName())) {
|
||||
dimension.setEntityAlias(identify.getEntityNames());
|
||||
return dimension;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user