mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 19:51:00 +00:00
(improvement)(headless)Optimize metric matching in populating data format.
This commit is contained in:
@@ -303,8 +303,8 @@ public class S2SemanticLayerService implements SemanticLayerService {
|
|||||||
|
|
||||||
QueryStatement queryStatement = new QueryStatement();
|
QueryStatement queryStatement = new QueryStatement();
|
||||||
queryStatement.setEnableOptimize(queryUtils.enableOptimize());
|
queryStatement.setEnableOptimize(queryUtils.enableOptimize());
|
||||||
queryStatement.setLimit(Integer.parseInt(translatorConfig.getParameterValue(
|
queryStatement.setLimit(Integer.parseInt(
|
||||||
TranslatorConfig.TRANSLATOR_RESULT_LIMIT)));
|
translatorConfig.getParameterValue(TranslatorConfig.TRANSLATOR_RESULT_LIMIT)));
|
||||||
queryStatement.setDataSetId(queryReq.getDataSetId());
|
queryStatement.setDataSetId(queryReq.getDataSetId());
|
||||||
queryStatement.setDataSetName(queryReq.getDataSetName());
|
queryStatement.setDataSetName(queryReq.getDataSetName());
|
||||||
queryStatement.setSemanticSchema(semanticSchemaResp);
|
queryStatement.setSemanticSchema(semanticSchemaResp);
|
||||||
|
|||||||
@@ -145,8 +145,7 @@ public class ModelServiceImpl implements ModelService {
|
|||||||
// Comment out below checks for now, they seem unnecessary and
|
// Comment out below checks for now, they seem unnecessary and
|
||||||
// lead to unexpected exception in updating model
|
// lead to unexpected exception in updating model
|
||||||
/*
|
/*
|
||||||
checkParams(modelReq);
|
* checkParams(modelReq); checkRelations(modelReq);
|
||||||
checkRelations(modelReq);
|
|
||||||
*/
|
*/
|
||||||
ModelDO modelDO = modelRepository.getModelById(modelReq.getId());
|
ModelDO modelDO = modelRepository.getModelById(modelReq.getId());
|
||||||
ModelConverter.convert(modelDO, modelReq, user);
|
ModelConverter.convert(modelDO, modelReq, user);
|
||||||
|
|||||||
@@ -109,7 +109,9 @@ public class ModelConverter {
|
|||||||
dimensionReq.setModelId(modelDO.getId());
|
dimensionReq.setModelId(modelDO.getId());
|
||||||
dimensionReq.setExpr(dim.getExpr());
|
dimensionReq.setExpr(dim.getExpr());
|
||||||
dimensionReq.setType(dim.getType().name());
|
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());
|
dimensionReq.setTypeParams(dim.getTypeParams());
|
||||||
return dimensionReq;
|
return dimensionReq;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,28 @@ public class QueryUtils {
|
|||||||
column.setDataFormatType(metricRespMap.get(nameEn).getDataFormatType());
|
column.setDataFormatType(metricRespMap.get(nameEn).getDataFormatType());
|
||||||
column.setDataFormat(metricRespMap.get(nameEn).getDataFormat());
|
column.setDataFormat(metricRespMap.get(nameEn).getDataFormat());
|
||||||
column.setModelId(metricRespMap.get(nameEn).getModelId());
|
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)) {
|
if (dimensionRespMap.containsKey(nameEn)) {
|
||||||
column.setModelId(dimensionRespMap.get(nameEn).getModelId());
|
column.setModelId(dimensionRespMap.get(nameEn).getModelId());
|
||||||
}
|
}
|
||||||
@@ -119,7 +140,7 @@ public class QueryUtils {
|
|||||||
|| type.equalsIgnoreCase("float") || type.equalsIgnoreCase("double")
|
|| type.equalsIgnoreCase("float") || type.equalsIgnoreCase("double")
|
||||||
|| type.equalsIgnoreCase("real") || type.equalsIgnoreCase("numeric")
|
|| type.equalsIgnoreCase("real") || type.equalsIgnoreCase("numeric")
|
||||||
|| type.toLowerCase().startsWith("decimal") || type.toLowerCase().startsWith("uint")
|
|| 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) {
|
private String getName(String nameEn) {
|
||||||
|
|||||||
Reference in New Issue
Block a user