mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 19:38:13 +00:00
[improvement][chat]Change query type resolution logic.
This commit is contained in:
@@ -30,10 +30,7 @@ public class SqlSelectFunctionHelper {
|
||||
Arrays.asList("SUM", "COUNT", "MAX", "MIN", "AVG");
|
||||
|
||||
public static boolean hasAggregateFunction(String sql) {
|
||||
if (!CollectionUtils.isEmpty(getFunctions(sql))) {
|
||||
return true;
|
||||
}
|
||||
return SqlSelectHelper.hasGroupBy(sql);
|
||||
return !CollectionUtils.isEmpty(getFunctions(sql));
|
||||
}
|
||||
|
||||
public static boolean hasFunction(String sql, String functionName) {
|
||||
|
||||
@@ -35,7 +35,7 @@ class SqlSelectFunctionHelperTest {
|
||||
hasAggregateFunction = SqlSelectFunctionHelper.hasAggregateFunction(sql);
|
||||
Assert.assertEquals(hasAggregateFunction, false);
|
||||
|
||||
sql = "SELECT user_name, pv FROM t_34 WHERE sys_imp_date <= '2023-09-03' "
|
||||
sql = "SELECT user_name, sum(pv) FROM t_34 WHERE sys_imp_date <= '2023-09-03' "
|
||||
+ "AND sys_imp_date >= '2023-08-04' GROUP BY user_name ORDER BY sum(pv) DESC LIMIT 10";
|
||||
hasAggregateFunction = SqlSelectFunctionHelper.hasAggregateFunction(sql);
|
||||
Assert.assertEquals(hasAggregateFunction, true);
|
||||
|
||||
@@ -68,9 +68,8 @@ public class QueryTypeParser implements SemanticParser {
|
||||
}
|
||||
}
|
||||
|
||||
// 2. metric queryType
|
||||
if (selectContainsMetric(sqlInfo, dataSetId, semanticSchema)
|
||||
|| SqlSelectFunctionHelper.hasAggregateFunction(sqlInfo.getParsedS2SQL())) {
|
||||
// 2. AGG queryType
|
||||
if (SqlSelectFunctionHelper.hasAggregateFunction(sqlInfo.getParsedS2SQL())) {
|
||||
return QueryType.AGGREGATE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user