This is an automated email from the ASF dual-hosted git repository. caogaofei pushed a commit to branch beyyes/improve_query_fe in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 6d93bd7ed7ed5e800279e55f6001187c02493cdc Author: Beyyes <[email protected]> AuthorDate: Sun Jun 25 17:49:05 2023 +0800 add more semantic restricts when using having clause --- .../iotdb/db/mpp/plan/statement/crud/QueryStatement.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/crud/QueryStatement.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/crud/QueryStatement.java index 93a9732c776..2cf6154a1c4 100644 --- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/crud/QueryStatement.java +++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/crud/QueryStatement.java @@ -549,8 +549,13 @@ public class QueryStatement extends Statement { != ResultColumn.ColumnType.AGGREGATION) { throw new SemanticException("Expression of HAVING clause must to be an Aggregation"); } + if (!isAggregationQuery()) { + throw new SemanticException( + "Expression of HAVING clause can not be used in NonAggregationQuery"); + } try { - if (isGroupByLevel()) { // check path in SELECT and HAVING only have one node + if (isGroupByLevel()) { + // check path in SELECT and HAVING only have one node for (ResultColumn resultColumn : getSelectComponent().getResultColumns()) { ExpressionAnalyzer.checkIsAllMeasurement(resultColumn.getExpression()); } @@ -579,6 +584,9 @@ public class QueryStatement extends Statement { if (getWhereCondition() != null) { ExpressionAnalyzer.checkIsAllMeasurement(getWhereCondition().getPredicate()); } + if (hasHaving()) { + ExpressionAnalyzer.checkIsAllMeasurement(getHavingCondition().getPredicate()); + } } catch (SemanticException e) { throw new SemanticException("ALIGN BY DEVICE: " + e.getMessage()); }
