liyuheng55555 commented on code in PR #9438:
URL: https://github.com/apache/iotdb/pull/9438#discussion_r1155515947


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/ExpressionAnalyzer.java:
##########
@@ -214,9 +216,40 @@ public static ResultColumn.ColumnType 
identifyOutputColumnType(
         }
         return checkedType;
       }
+    } else if (expression instanceof CaseWhenThenExpression) {
+      // first, get all subexpression's type
+      CaseWhenThenExpression caseExpression = (CaseWhenThenExpression) 
expression;
+      List<ResultColumn.ColumnType> typeList =
+          caseExpression.getExpressions().stream()
+              .map(e -> identifyOutputColumnType(e, false))
+              .collect(Collectors.toList());
+      // if at least one subexpression is RAW, I'm RAW too
+      boolean rawFlag =
+          typeList.stream().anyMatch(columnType -> columnType == 
ResultColumn.ColumnType.RAW);
+      // if at least one subexpression is AGGREGATION, I'm AGGREGATION too
+      boolean aggregationFlag =
+          typeList.stream()
+              .anyMatch(columnType -> columnType == 
ResultColumn.ColumnType.AGGREGATION);
+      // not allow RAW && AGGREGATION
+      if (rawFlag && aggregationFlag) {
+        throw new SemanticException(
+            "Raw data and aggregation result hybrid calculation is not 
supported.");
+      }
+      // not allow all const
+      boolean allConst =
+          typeList.stream().allMatch(columnType -> columnType == 
ResultColumn.ColumnType.CONSTANT);
+      if (allConst) {
+        throw new SemanticException("Constant column is not supported.");
+      }
+      for (ResultColumn.ColumnType type : typeList) {
+        if (type != ResultColumn.ColumnType.CONSTANT) {
+          return type;
+        }
+      }
+      throw new IllegalArgumentException("shouldn't attach here");

Review Comment:
   needn't change



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to