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


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java:
##########
@@ -2430,6 +2437,58 @@ private Expression parseRoundFunction(
     return functionExpression;
   }
 
+  private CaseWhenThenExpression parseCaseWhenThenExpression(
+      IoTDBSqlParser.CaseWhenThenExpressionContext context, boolean 
canUseFullPath) {
+    if (context.caseWhenThenExpression1() != null) {
+      return parseCaseWhenThenExpression1(context.caseWhenThenExpression1(), 
canUseFullPath);
+    }
+
+    if (context.caseWhenThenExpression2() != null) {
+      return parseCaseWhenThenExpression2(context.caseWhenThenExpression2(), 
canUseFullPath);
+    }
+
+    throw new UnsupportedOperationException();
+  }
+
+  private CaseWhenThenExpression parseCaseWhenThenExpression1(
+      IoTDBSqlParser.CaseWhenThenExpression1Context context, boolean 
canUseFullPath) {
+    List<WhenThenExpression> whenThenList = new ArrayList<>();
+    for (IoTDBSqlParser.WhenThenExpressionContext whenThenExpressionContext :
+        context.whenThenExpression()) {
+      whenThenList.add(parseWhenThenExpression(whenThenExpressionContext, 
canUseFullPath));
+    }
+    Expression elseExpression = new NullOperand();
+    if (context.elseExpression != null) {
+      elseExpression = parseExpression(context.elseExpression, canUseFullPath);
+    }
+    return new CaseWhenThenExpression(whenThenList, elseExpression);
+  }
+
+  private CaseWhenThenExpression parseCaseWhenThenExpression2(
+      IoTDBSqlParser.CaseWhenThenExpression2Context context, boolean 
canUseFullPath) {
+    Expression caseExpression = parseExpression(context.caseExpression, 
canUseFullPath);
+    List<WhenThenExpression> whenThenList = new ArrayList<>();
+    for (IoTDBSqlParser.WhenThenExpressionContext whenThenExpressionContext :
+        context.whenThenExpression()) {
+      Expression when = 
parseExpression(whenThenExpressionContext.whenExpression, canUseFullPath);
+      Expression then = 
parseExpression(whenThenExpressionContext.thenExpression, canUseFullPath);
+      Expression comparison = new EqualToExpression(caseExpression, when);
+      whenThenList.add(new WhenThenExpression(comparison, then));
+    }
+    Expression elseExpression = new NullOperand();
+    if (context.elseExpression != null) {
+      elseExpression = parseExpression(context.elseExpression, canUseFullPath);
+    }
+    return new CaseWhenThenExpression(whenThenList, elseExpression);
+  }

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