mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-15 22:46:49 +00:00
(improvement)(headless)Remove tag-related logic when determining query type.
This commit is contained in:
@@ -52,6 +52,7 @@ public class QueryTypeParser implements SemanticParser {
|
|||||||
if (Objects.isNull(sqlInfo) || StringUtils.isBlank(sqlInfo.getParsedS2SQL())) {
|
if (Objects.isNull(sqlInfo) || StringUtils.isBlank(sqlInfo.getParsedS2SQL())) {
|
||||||
return QueryType.DETAIL;
|
return QueryType.DETAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//1. entity queryType
|
//1. entity queryType
|
||||||
Long dataSetId = parseInfo.getDataSetId();
|
Long dataSetId = parseInfo.getDataSetId();
|
||||||
SemanticSchema semanticSchema = chatQueryContext.getSemanticSchema();
|
SemanticSchema semanticSchema = chatQueryContext.getSemanticSchema();
|
||||||
@@ -66,23 +67,13 @@ public class QueryTypeParser implements SemanticParser {
|
|||||||
return QueryType.ID;
|
return QueryType.ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<String> selectFields = SqlSelectHelper.getSelectFields(sqlInfo.getParsedS2SQL());
|
|
||||||
selectFields.addAll(whereFields);
|
|
||||||
List<String> selectWhereFilterByTimeFields = filterByTimeFields(selectFields);
|
|
||||||
if (CollectionUtils.isNotEmpty(selectWhereFilterByTimeFields)) {
|
|
||||||
Set<String> tags = semanticSchema.getTags(dataSetId).stream().map(SchemaElement::getName)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
//If all the fields in the SELECT/WHERE statement are of tag type.
|
|
||||||
if (CollectionUtils.isNotEmpty(tags)
|
|
||||||
&& tags.containsAll(selectWhereFilterByTimeFields)) {
|
|
||||||
return QueryType.DETAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//2. metric queryType
|
//2. metric queryType
|
||||||
if (selectContainsMetric(sqlInfo, dataSetId, semanticSchema)) {
|
if (selectContainsMetric(sqlInfo, dataSetId, semanticSchema)) {
|
||||||
return QueryType.METRIC;
|
return QueryType.METRIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QueryType.DETAIL;
|
return QueryType.DETAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user