Merge pull request #759 from lexluo09/master

(improvement)(project) merge master to dev-0.9
This commit is contained in:
lexluo09
2024-02-26 14:41:23 +08:00
committed by GitHub
142 changed files with 2041 additions and 664 deletions

View File

@@ -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(";")) {

View File

@@ -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();
}
}

View File

@@ -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);
}
}

View File

@@ -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();
}

View File

@@ -0,0 +1,7 @@
package com.tencent.supersonic.headless.api.pojo.enums;
public enum VariableValueType {
STRING,
NUMBER,
EXPR
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -16,8 +16,6 @@ public class ViewReq extends SchemaItem {
private String alias;
private String filterSql;
private QueryConfig queryConfig;
private List<String> admins;

View File

@@ -30,6 +30,8 @@ public class MetricResp extends SchemaItem {
private Long domainId;
private String modelBizName;
private String modelName;
//ATOMIC DERIVED

View File

@@ -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;
}
}