mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 12:37:55 +00:00
[improvement](chat) When determining the query type, S2SQL is uniformly used for parsing. (#393)
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user