You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2021/05/17 13:48:43 UTC

[iotdb] 01/03: fix checkAggregation

This is an automated email from the ASF dual-hosted git repository.

rong pushed a commit to branch iotdb-1022-v2
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit c1ff734ff57e9c31eaff813043b2e7d9e37904ac
Author: SteveYurongSu <st...@outlook.com>
AuthorDate: Fri May 14 19:54:02 2021 +0800

    fix checkAggregation
---
 .../org/apache/iotdb/db/qp/strategy/LogicalChecker.java  | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalChecker.java b/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalChecker.java
index b5a4202..cec031c 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalChecker.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalChecker.java
@@ -24,6 +24,9 @@ import org.apache.iotdb.db.metadata.PartialPath;
 import org.apache.iotdb.db.qp.logical.Operator;
 import org.apache.iotdb.db.qp.logical.crud.QueryOperator;
 import org.apache.iotdb.db.qp.logical.crud.SelectOperator;
+import org.apache.iotdb.db.query.expression.Expression;
+import org.apache.iotdb.db.query.expression.ResultColumn;
+import org.apache.iotdb.db.query.expression.unary.TimeSeriesOperand;
 
 public class LogicalChecker {
 
@@ -51,10 +54,15 @@ public class LogicalChecker {
   private static void checkAggregation(QueryOperator queryOperator)
       throws LogicalOperatorException {
     SelectOperator selectOperator = queryOperator.getSelectOperator();
-    if (!selectOperator.getResultColumns().isEmpty()
-        && selectOperator.getPaths().size() != selectOperator.getAggregationFunctions().size()) {
-      throw new LogicalOperatorException(
-          "Common queries and aggregated queries are not allowed to appear at the same time");
+    if (!selectOperator.hasAggregationFunction()) {
+      return;
+    }
+    for (ResultColumn resultColumn : selectOperator.getResultColumns()) {
+      Expression expression = resultColumn.getExpression();
+      if (expression instanceof TimeSeriesOperand) {
+        throw new LogicalOperatorException(
+            "Common queries and aggregated queries are not allowed to appear at the same time");
+      }
     }
   }