(improvement)(headless)Optimize metric matching in populating data format.
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

This commit is contained in:
jerryjzhang
2025-02-20 19:06:55 +08:00
parent 1155ac10d8
commit 1e01f3ef60
4 changed files with 28 additions and 6 deletions

View File

@@ -303,8 +303,8 @@ public class S2SemanticLayerService implements SemanticLayerService {
QueryStatement queryStatement = new QueryStatement();
queryStatement.setEnableOptimize(queryUtils.enableOptimize());
queryStatement.setLimit(Integer.parseInt(translatorConfig.getParameterValue(
TranslatorConfig.TRANSLATOR_RESULT_LIMIT)));
queryStatement.setLimit(Integer.parseInt(
translatorConfig.getParameterValue(TranslatorConfig.TRANSLATOR_RESULT_LIMIT)));
queryStatement.setDataSetId(queryReq.getDataSetId());
queryStatement.setDataSetName(queryReq.getDataSetName());
queryStatement.setSemanticSchema(semanticSchemaResp);

View File

@@ -145,8 +145,7 @@ public class ModelServiceImpl implements ModelService {
// Comment out below checks for now, they seem unnecessary and
// lead to unexpected exception in updating model
/*
checkParams(modelReq);
checkRelations(modelReq);
* checkParams(modelReq); checkRelations(modelReq);
*/
ModelDO modelDO = modelRepository.getModelById(modelReq.getId());
ModelConverter.convert(modelDO, modelReq, user);

View File

@@ -109,7 +109,9 @@ public class ModelConverter {
dimensionReq.setModelId(modelDO.getId());
dimensionReq.setExpr(dim.getExpr());
dimensionReq.setType(dim.getType().name());
dimensionReq.setDescription(Objects.isNull(dim.getDescription()) ? dimensionReq.getDescription() : dim.getDescription());
dimensionReq
.setDescription(Objects.isNull(dim.getDescription()) ? dimensionReq.getDescription()
: dim.getDescription());
dimensionReq.setTypeParams(dim.getTypeParams());
return dimensionReq;
}

View File

@@ -100,7 +100,28 @@ public class QueryUtils {
column.setDataFormatType(metricRespMap.get(nameEn).getDataFormatType());
column.setDataFormat(metricRespMap.get(nameEn).getDataFormat());
column.setModelId(metricRespMap.get(nameEn).getModelId());
} else {
// if column nameEn contains metric name, use metric dataFormatType
metricRespMap.values().forEach(metric -> {
if (nameEn.contains(metric.getName()) || nameEn.contains(metric.getBizName())) {
column.setDataFormatType(metric.getDataFormatType());
column.setDataFormat(metric.getDataFormat());
column.setModelId(metric.getModelId());
}
// if column nameEn contains metric alias, use metric dataFormatType
if (column.getDataFormatType() == null && metric.getAlias() != null) {
for (String alias : metric.getAlias().split(",")) {
if (nameEn.contains(alias)) {
column.setDataFormatType(metric.getDataFormatType());
column.setDataFormat(metric.getDataFormat());
column.setModelId(metric.getModelId());
break;
}
}
}
});
}
if (dimensionRespMap.containsKey(nameEn)) {
column.setModelId(dimensionRespMap.get(nameEn).getModelId());
}
@@ -119,7 +140,7 @@ public class QueryUtils {
|| type.equalsIgnoreCase("float") || type.equalsIgnoreCase("double")
|| type.equalsIgnoreCase("real") || type.equalsIgnoreCase("numeric")
|| type.toLowerCase().startsWith("decimal") || type.toLowerCase().startsWith("uint")
|| type.toLowerCase().startsWith("int");
|| type.toLowerCase().startsWith("int") || type.toLowerCase().equalsIgnoreCase("decfloat");
}
private String getName(String nameEn) {