[improvement](chat) When determining the query type, S2SQL is uniformly used for parsing. (#393)

This commit is contained in:
lexluo09
2023-11-16 17:39:46 +08:00
committed by GitHub
parent 46a9e5b097
commit 11cdcb29fa

View File

@@ -58,12 +58,14 @@ public class QueryTypeParser implements SemanticParser {
// get primaryEntityBizName // get primaryEntityBizName
SemanticService semanticService = ContextUtils.getBean(SemanticService.class); SemanticService semanticService = ContextUtils.getBean(SemanticService.class);
EntityInfo entityInfo = semanticService.getEntityInfo(parseInfo, user); EntityInfo entityInfo = semanticService.getEntityInfo(parseInfo, user);
String primaryEntityBizName = semanticService.getPrimaryEntityBizName(entityInfo); if (Objects.nonNull(entityInfo) && Objects.nonNull(entityInfo.getModelInfo()) && StringUtils.isNotEmpty(
if (StringUtils.isNotEmpty(primaryEntityBizName)) { entityInfo.getModelInfo().getPrimaryEntityName())) {
//if exist primaryEntityBizName in parseInfo's dimensions, set nativeQuery to true String primaryEntityName = entityInfo.getModelInfo().getPrimaryEntityName();
boolean existPrimaryEntityBizName = parseInfo.getDimensions().stream() //if exist primaryEntityName in S2SQL select.
.anyMatch(schemaElement -> primaryEntityBizName.equalsIgnoreCase(schemaElement.getBizName())); List<String> selectFields = SqlParserSelectHelper.getSelectFields(sqlInfo.getS2SQL());
if (existPrimaryEntityBizName) { boolean existPrimaryEntityName = selectFields.stream()
.anyMatch(fieldName -> primaryEntityName.equalsIgnoreCase(fieldName));
if (existPrimaryEntityName) {
return QueryType.ENTITY; return QueryType.ENTITY;
} }
} }