liuminghui233 commented on code in PR #9242:
URL: https://github.com/apache/iotdb/pull/9242#discussion_r1130360403


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java:
##########
@@ -303,6 +307,9 @@ public Analysis visitQuery(QueryStatement queryStatement, 
MPPQueryContext contex
       } else {
         Map<Integer, List<Pair<Expression, String>>> outputExpressionMap =
             analyzeSelect(analysis, queryStatement, schemaTree);
+        if (outputExpressionMap.values().stream().allMatch(List::isEmpty)) {
+          return finishQuery(analysis);
+        }

Review Comment:
   It's better to check `outputExpressions` below. That way we don't need to 
traverse the outputExpressionMap twice.



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java:
##########
@@ -350,6 +357,11 @@ public Analysis visitQuery(QueryStatement queryStatement, 
MPPQueryContext contex
     return analysis;
   }
 
+  private Analysis finishQuery(Analysis analysis) {
+    analysis.setFinishQueryAfterAnalyze(true);

Review Comment:
   We need to set empty headers in different formats.
   ```suggestion
   if (queryStatement.isSelectInto()) {
             analysis.setRespDatasetHeader(
               
DatasetHeaderFactory.getSelectIntoHeader(queryStatement.isAlignByDevice()));
           }
           if (queryStatement.isLastQuery()) {
          
analysis.setRespDatasetHeader(DatasetHeaderFactory.getLastQueryHeader());
           }
       analysis.setFinishQueryAfterAnalyze(true);
   ```



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