mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-30 04:54:25 +08:00
Compare commits
4 Commits
94e8ca61fb
...
b0fc5e73ce
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0fc5e73ce | ||
|
|
79a44b27ee | ||
|
|
76cc5ee111 | ||
|
|
469a229bb9 |
@@ -1,5 +1,6 @@
|
|||||||
package com.tencent.supersonic.headless.core.pojo;
|
package com.tencent.supersonic.headless.core.pojo;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.common.pojo.User;
|
||||||
import com.tencent.supersonic.headless.api.pojo.response.QueryState;
|
import com.tencent.supersonic.headless.api.pojo.response.QueryState;
|
||||||
import com.tencent.supersonic.headless.api.pojo.response.SemanticSchemaResp;
|
import com.tencent.supersonic.headless.api.pojo.response.SemanticSchemaResp;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -24,6 +25,7 @@ public class QueryStatement {
|
|||||||
private SemanticSchemaResp semanticSchema;
|
private SemanticSchemaResp semanticSchema;
|
||||||
private Integer limit = 1000;
|
private Integer limit = 1000;
|
||||||
private Boolean isTranslated = false;
|
private Boolean isTranslated = false;
|
||||||
|
private User user;
|
||||||
|
|
||||||
public boolean isOk() {
|
public boolean isOk() {
|
||||||
return StringUtils.isBlank(errMsg) && StringUtils.isNotBlank(sql);
|
return StringUtils.isBlank(errMsg) && StringUtils.isNotBlank(sql);
|
||||||
|
|||||||
@@ -296,6 +296,9 @@ public class S2SemanticLayerService implements SemanticLayerService {
|
|||||||
queryStatement.setSql(semanticQueryReq.getSqlInfo().getQuerySQL());
|
queryStatement.setSql(semanticQueryReq.getSqlInfo().getQuerySQL());
|
||||||
queryStatement.setIsTranslated(true);
|
queryStatement.setIsTranslated(true);
|
||||||
}
|
}
|
||||||
|
if (queryStatement != null) {
|
||||||
|
queryStatement.setUser(user);
|
||||||
|
}
|
||||||
return queryStatement;
|
return queryStatement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,8 @@ public class ChatWorkflowEngine {
|
|||||||
// 如果物理SQL被修正了,更新querySQL为修正后的版本
|
// 如果物理SQL被修正了,更新querySQL为修正后的版本
|
||||||
SemanticParseInfo parseInfo = semanticQuery.getParseInfo();
|
SemanticParseInfo parseInfo = semanticQuery.getParseInfo();
|
||||||
if (StringUtils.isNotBlank(parseInfo.getSqlInfo().getCorrectedQuerySQL())) {
|
if (StringUtils.isNotBlank(parseInfo.getSqlInfo().getCorrectedQuerySQL())) {
|
||||||
parseInfo.getSqlInfo().setQuerySQL(parseInfo.getSqlInfo().getCorrectedQuerySQL());
|
parseInfo.getSqlInfo()
|
||||||
|
.setQuerySQL(parseInfo.getSqlInfo().getCorrectedQuerySQL());
|
||||||
log.info("Physical SQL corrected and updated querySQL: {}",
|
log.info("Physical SQL corrected and updated querySQL: {}",
|
||||||
parseInfo.getSqlInfo().getQuerySQL());
|
parseInfo.getSqlInfo().getQuerySQL());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,7 +138,8 @@ public class DictUtils {
|
|||||||
semanticQueryReq.setNeedAuth(false);
|
semanticQueryReq.setNeedAuth(false);
|
||||||
String bizName = dictItemResp.getBizName();
|
String bizName = dictItemResp.getBizName();
|
||||||
try {
|
try {
|
||||||
SemanticQueryResp semanticQueryResp = queryService.queryByReq(semanticQueryReq, null);
|
SemanticQueryResp semanticQueryResp =
|
||||||
|
queryService.queryByReq(semanticQueryReq, User.getDefaultUser());
|
||||||
if (Objects.isNull(semanticQueryResp)
|
if (Objects.isNull(semanticQueryResp)
|
||||||
|| CollectionUtils.isEmpty(semanticQueryResp.getResultList())) {
|
|| CollectionUtils.isEmpty(semanticQueryResp.getResultList())) {
|
||||||
return lines;
|
return lines;
|
||||||
@@ -274,7 +275,8 @@ public class DictUtils {
|
|||||||
private QuerySqlReq constructQuerySqlReq(DictItemResp dictItemResp) {
|
private QuerySqlReq constructQuerySqlReq(DictItemResp dictItemResp) {
|
||||||
|
|
||||||
ModelResp model = modelService.getModel(dictItemResp.getModelId());
|
ModelResp model = modelService.getModel(dictItemResp.getModelId());
|
||||||
String tableStr = model.getModelDetail().getTableQuery() != null ? model.getModelDetail().getTableQuery()
|
String tableStr = StringUtils.isNotBlank(model.getModelDetail().getTableQuery())
|
||||||
|
? model.getModelDetail().getTableQuery()
|
||||||
: "(" + model.getModelDetail().getSqlQuery() + ")";
|
: "(" + model.getModelDetail().getSqlQuery() + ")";
|
||||||
String sqlPattern =
|
String sqlPattern =
|
||||||
"select %s,count(1) from %s %s group by %s order by count(1) desc limit %d";
|
"select %s,count(1) from %s %s group by %s order by count(1) desc limit %d";
|
||||||
@@ -289,8 +291,7 @@ public class DictUtils {
|
|||||||
limit = Integer.MAX_VALUE;
|
limit = Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
String sql =
|
String sql = String.format(sqlPattern, dimBizName, tableStr, where, dimBizName, limit);
|
||||||
String.format(sqlPattern, dimBizName, tableStr, where, dimBizName, limit);
|
|
||||||
Set<Long> modelIds = new HashSet<>();
|
Set<Long> modelIds = new HashSet<>();
|
||||||
modelIds.add(dictItemResp.getModelId());
|
modelIds.add(dictItemResp.getModelId());
|
||||||
QuerySqlReq querySqlReq = new QuerySqlReq();
|
QuerySqlReq querySqlReq = new QuerySqlReq();
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ public class QueryUtils {
|
|||||||
column.setModelId(metric.getModelId());
|
column.setModelId(metric.getModelId());
|
||||||
}
|
}
|
||||||
// if column nameEn contains metric alias, use metric dataFormatType
|
// if column nameEn contains metric alias, use metric dataFormatType
|
||||||
if (column.getDataFormatType() == null && StringUtils.isNotEmpty(metric.getAlias())) {
|
if (column.getDataFormatType() == null
|
||||||
|
&& StringUtils.isNotEmpty(metric.getAlias())) {
|
||||||
for (String alias : metric.getAlias().split(",")) {
|
for (String alias : metric.getAlias().split(",")) {
|
||||||
if (nameEn.contains(alias)) {
|
if (nameEn.contains(alias)) {
|
||||||
column.setDataFormatType(metric.getDataFormatType());
|
column.setDataFormatType(metric.getDataFormatType());
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ const Table: React.FC<Props> = ({ data, size, loading, question, onApplyAuth })
|
|||||||
dataIndex: bizName,
|
dataIndex: bizName,
|
||||||
key: bizName,
|
key: bizName,
|
||||||
title: name || bizName,
|
title: name || bizName,
|
||||||
defaultSortOrder: 'descend',
|
|
||||||
sorter:
|
sorter:
|
||||||
showType === 'NUMBER'
|
showType === 'NUMBER'
|
||||||
? (a, b) => {
|
? (a, b) => {
|
||||||
@@ -73,10 +72,11 @@ const Table: React.FC<Props> = ({ data, size, loading, question, onApplyAuth })
|
|||||||
return index % 2 !== 0 ? `${prefixCls}-even-row` : '';
|
return index % 2 !== 0 ? `${prefixCls}-even-row` : '';
|
||||||
};
|
};
|
||||||
|
|
||||||
const dateColumn = queryColumns.find(column => column.type === 'DATE');
|
const dateColumn = queryColumns.find(column => column.type === 'DATE' || column.showType === 'DATE');
|
||||||
const dataSource = dateColumn
|
const dataSource = dateColumn
|
||||||
? queryResults.sort((a, b) => moment(a[dateColumn.bizName]).diff(moment(b[dateColumn.bizName])))
|
? queryResults.sort((a, b) => moment(a[dateColumn.bizName]).diff(moment(b[dateColumn.bizName])))
|
||||||
: queryResults;
|
: queryResults;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={prefixCls}>
|
<div className={prefixCls}>
|
||||||
{question && (
|
{question && (
|
||||||
|
|||||||
Reference in New Issue
Block a user