mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 20:51:48 +00:00
(improvement)(chat) Adding the Metric API to Headless. (#738)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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