shizy818 commented on code in PR #16353:
URL: https://github.com/apache/iotdb/pull/16353#discussion_r2645087594


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/MPPQueryContext.java:
##########
@@ -103,6 +125,24 @@ public class MPPQueryContext implements IAuditEntity {
 
   private boolean userQuery = false;
 
+  private Map<NodeRef<Table>, Query> cteQueries = new HashMap<>();
+
+  // Stores the EXPLAIN/EXPLAIN ANALYZE results for Common Table Expressions 
(CTEs)
+  // Key: CTE table reference
+  // Value: Pair containing (max line length of the explain output, list of 
formatted explain lines)
+  // This ensures consistent formatting between the main query and its CTE 
sub-queries
+  private final Map<NodeRef<Table>, Pair<Integer, List<String>>> 
cteExplainResults =
+      new LinkedHashMap<>();
+  // Tracks the materialization time cost (in nanoseconds) for each CTE to 
help optimize query
+  // planning
+  private final Map<NodeRef<Table>, Long> cteMaterializationCosts = new 
HashMap<>();
+
+  // Never materialize CTE in a subquery.
+  private boolean subquery = false;

Review Comment:
   I just mean subquery. It is used in `createOutputPlan`, `createRelationPlan` 
and `createRelationPlan`.  As long as it's subquery, I think the logic is same.



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