3 Commits

Author SHA1 Message Date
wangyong
4a761a49bf Merge 66ad18f4d3 into 76cc5ee111 2025-06-27 23:30:54 +08:00
jerryjzhang
76cc5ee111 [opt][heaadless]Add user field to QueryStatement for consistency.
Some checks are pending
supersonic CentOS CI / build (21) (push) Waiting to run
supersonic mac CI / build (21) (push) Waiting to run
supersonic ubuntu CI / build (21) (push) Waiting to run
supersonic windows CI / build (21) (push) Waiting to run
2025-06-27 19:46:00 +08:00
wangyong
66ad18f4d3 fixed bug 2281 2025-06-25 10:37:11 +08:00
8 changed files with 32 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
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.SemanticSchemaResp;
import lombok.Data;
@@ -24,6 +25,7 @@ public class QueryStatement {
private SemanticSchemaResp semanticSchema;
private Integer limit = 1000;
private Boolean isTranslated = false;
private User user;
public boolean isOk() {
return StringUtils.isBlank(errMsg) && StringUtils.isNotBlank(sql);

View File

@@ -296,6 +296,9 @@ public class S2SemanticLayerService implements SemanticLayerService {
queryStatement.setSql(semanticQueryReq.getSqlInfo().getQuerySQL());
queryStatement.setIsTranslated(true);
}
if (queryStatement != null) {
queryStatement.setUser(user);
}
return queryStatement;
}

View File

@@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.List;
@RestController
@@ -50,10 +51,8 @@ public class DataSetController {
@GetMapping("/getDataSetList")
public List<DataSetResp> getDataSetList(@RequestParam("domainId") Long domainId) {
MetaFilter metaFilter = new MetaFilter();
metaFilter.setDomainId(domainId);
metaFilter.setStatus(StatusEnum.ONLINE.getCode());
return dataSetService.getDataSetList(metaFilter);
List<Integer> statuCodeList = Arrays.asList(StatusEnum.ONLINE.getCode(),StatusEnum.OFFLINE.getCode());
return dataSetService.getDataSetList(domainId,statuCodeList);
}
@DeleteMapping("/{id}")

View File

@@ -20,6 +20,8 @@ public interface DataSetService {
List<DataSetResp> getDataSetList(MetaFilter metaFilter);
List<DataSetResp> getDataSetList(Long domainId ,List<Integer> statuCodesList);
void delete(Long id, User user);
Map<Long, List<Long>> getModelIdToDataSetIds(List<Long> dataSetIds, User user);

View File

@@ -102,6 +102,20 @@ public class DataSetServiceImpl extends ServiceImpl<DataSetDOMapper, DataSetDO>
return list(wrapper).stream().map(this::convert).collect(Collectors.toList());
}
@Override
public List<DataSetResp> getDataSetList(Long domainId, List<Integer> statuCodesList) {
if(domainId==null || CollectionUtils.isEmpty(statuCodesList)){
return List.of();
}
QueryWrapper<DataSetDO> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(DataSetDO::getDomainId, domainId);
wrapper.lambda().in(DataSetDO::getStatus, statuCodesList);
wrapper.lambda().ne(DataSetDO::getStatus, StatusEnum.DELETED.getCode());
return list(wrapper).stream().map(this::convert).collect(Collectors.toList());
}
@Override
public void delete(Long id, User user) {
DataSetDO dataSetDO = getById(id);

View File

@@ -178,8 +178,9 @@ public class ChatWorkflowEngine {
// 如果物理SQL被修正了更新querySQL为修正后的版本
SemanticParseInfo parseInfo = semanticQuery.getParseInfo();
if (StringUtils.isNotBlank(parseInfo.getSqlInfo().getCorrectedQuerySQL())) {
parseInfo.getSqlInfo().setQuerySQL(parseInfo.getSqlInfo().getCorrectedQuerySQL());
log.info("Physical SQL corrected and updated querySQL: {}",
parseInfo.getSqlInfo()
.setQuerySQL(parseInfo.getSqlInfo().getCorrectedQuerySQL());
log.info("Physical SQL corrected and updated querySQL: {}",
parseInfo.getSqlInfo().getQuerySQL());
}
break;

View File

@@ -274,7 +274,8 @@ public class DictUtils {
private QuerySqlReq constructQuerySqlReq(DictItemResp dictItemResp) {
ModelResp model = modelService.getModel(dictItemResp.getModelId());
String tableStr = model.getModelDetail().getTableQuery() != null ? model.getModelDetail().getTableQuery()
String tableStr = model.getModelDetail().getTableQuery() != null
? model.getModelDetail().getTableQuery()
: "(" + model.getModelDetail().getSqlQuery() + ")";
String sqlPattern =
"select %s,count(1) from %s %s group by %s order by count(1) desc limit %d";
@@ -289,8 +290,7 @@ public class DictUtils {
limit = Integer.MAX_VALUE;
}
String sql =
String.format(sqlPattern, dimBizName, tableStr, where, dimBizName, limit);
String sql = String.format(sqlPattern, dimBizName, tableStr, where, dimBizName, limit);
Set<Long> modelIds = new HashSet<>();
modelIds.add(dictItemResp.getModelId());
QuerySqlReq querySqlReq = new QuerySqlReq();

View File

@@ -109,7 +109,8 @@ public class QueryUtils {
column.setModelId(metric.getModelId());
}
// 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(",")) {
if (nameEn.contains(alias)) {
column.setDataFormatType(metric.getDataFormatType());