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


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/ExpressionTypeAnalyzer.java:
##########
@@ -296,6 +300,52 @@ public TSDataType visitNullOperand(NullOperand 
nullOperand, Void context) {
       return null;
     }
 
+    @Override
+    public TSDataType visitCaseWhenThenExpression(
+        CaseWhenThenExpression caseWhenThenExpression, Void context) {
+      Set<TSDataType> typeSet = new HashSet<>();
+      for (WhenThenExpression whenThenExpression :
+          caseWhenThenExpression.getWhenThenExpressions()) {
+        typeSet.add(process(whenThenExpression, context));
+      }
+      TSDataType elseType = 
process(caseWhenThenExpression.getElseExpression(), context);
+      if (elseType != null) {
+        typeSet.add(elseType);
+      }
+      // if TEXT exist, every branch need to be TEXT
+      if (typeSet.contains(TSDataType.TEXT)) {
+        if (typeSet.stream().anyMatch(tsDataType -> tsDataType != 
TSDataType.TEXT)) {
+          throw new SemanticException(
+              "CASE expression: TEXT and other types cannot exist at same 
time");

Review Comment:
   done.



-- 
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