forked from github/dataease
Merge pull request #9692 from dataease/pr@dev-v2@fix_ds_count
fix(数据集): 修复数据集预览总数不正确的问题
This commit is contained in:
commit
e108dfc322
@ -231,28 +231,32 @@ public class DatasetDataManage {
|
|||||||
map.put("allFields", fieldList);
|
map.put("allFields", fieldList);
|
||||||
}
|
}
|
||||||
map.put("sql", Base64.getEncoder().encodeToString(querySQL.getBytes()));
|
map.put("sql", Base64.getEncoder().encodeToString(querySQL.getBytes()));
|
||||||
map.put("total", getDatasetTotal(datasetGroupInfoDTO));
|
map.put("total", getDatasetTotal(datasetGroupInfoDTO, SqlUtils.rebuildSQL(SQLProvider.createQuerySQL(sqlMeta, false, false, needOrder), sqlMeta, crossDs, dsMap)));
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getDatasetTotal(Long datasetGroupId) throws Exception {
|
public Long getDatasetTotal(Long datasetGroupId) throws Exception {
|
||||||
DatasetGroupInfoDTO dto = datasetGroupManage.getForCount(datasetGroupId);
|
DatasetGroupInfoDTO dto = datasetGroupManage.getForCount(datasetGroupId);
|
||||||
if (StringUtils.equalsIgnoreCase(dto.getNodeType(), "dataset")) {
|
if (StringUtils.equalsIgnoreCase(dto.getNodeType(), "dataset")) {
|
||||||
return getDatasetTotal(dto);
|
return getDatasetTotal(dto, null);
|
||||||
}
|
}
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getDatasetTotal(DatasetGroupInfoDTO datasetGroupInfoDTO) throws Exception {
|
public Long getDatasetTotal(DatasetGroupInfoDTO datasetGroupInfoDTO, String s) throws Exception {
|
||||||
Map<String, Object> sqlMap = datasetSQLManage.getUnionSQLForEdit(datasetGroupInfoDTO, null);
|
Map<String, Object> sqlMap = datasetSQLManage.getUnionSQLForEdit(datasetGroupInfoDTO, null);
|
||||||
String sql = (String) sqlMap.get("sql");
|
|
||||||
|
|
||||||
Map<Long, DatasourceSchemaDTO> dsMap = (Map<Long, DatasourceSchemaDTO>) sqlMap.get("dsMap");
|
Map<Long, DatasourceSchemaDTO> dsMap = (Map<Long, DatasourceSchemaDTO>) sqlMap.get("dsMap");
|
||||||
boolean crossDs = Utils.isCrossDs(dsMap);
|
|
||||||
if (!crossDs) {
|
|
||||||
sql = Utils.replaceSchemaAlias(sql, dsMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
String sql;
|
||||||
|
if (StringUtils.isEmpty(s)) {
|
||||||
|
sql = (String) sqlMap.get("sql");
|
||||||
|
boolean crossDs = Utils.isCrossDs(dsMap);
|
||||||
|
if (!crossDs) {
|
||||||
|
sql = Utils.replaceSchemaAlias(sql, dsMap);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sql = s;
|
||||||
|
}
|
||||||
String querySQL = "SELECT COUNT(*) FROM (" + sql + ") t_a_0";
|
String querySQL = "SELECT COUNT(*) FROM (" + sql + ") t_a_0";
|
||||||
logger.info("calcite data count sql: " + querySQL);
|
logger.info("calcite data count sql: " + querySQL);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user