Caideyipi commented on PR #17430:
URL: https://github.com/apache/iotdb/pull/17430#issuecomment-4628019266

   I found a few functional issues in the new JSON explain path:
   
   1. `EXPLAIN (FORMAT JSON)` with materialized CTEs can fail. CTE subqueries 
only inherit `ExplainType`, not the requested `ExplainOutputFormat` 
(`CteMaterializer` -> `Coordinator.executeForTableModel`). The inner CTE 
explain plan is still captured via `PlanGraphPrinter` text output in 
`TableDistributedPlanner`, but 
`TableModelStatementMemorySourceVisitor.mergeExplainResultsJson()` later parses 
that CTE result with `JsonParser.parseString(...)`. A query like this should be 
covered:
   
   ```sql
   EXPLAIN (FORMAT JSON)
   WITH cte1 AS MATERIALIZED (SELECT * FROM t)
   SELECT * FROM cte1;
   ```
   
   2. `EXPLAIN ... EXECUTE` and `EXPLAIN ... EXECUTE IMMEDIATE` lose the 
requested format when the prepared/immediate SQL is unwrapped in `Coordinator`. 
The code recreates `new Explain(resolvedSql)` / `new 
ExplainAnalyze(resolvedSql, verbose)`, which resets the format to `GRAPHVIZ` / 
`TEXT`, so `EXPLAIN (FORMAT JSON) EXECUTE stmt` and `EXPLAIN ANALYZE (FORMAT 
JSON) EXECUTE stmt` will not return JSON.
   
   3. In JSON analyze mode, `ExplainAnalyzeOperator` sets 
`fragmentInstanceStatisticsDrawer` to `null`, but the scheduled intermediate 
logger still calls `buildFragmentInstanceStatistics()`, which dereferences that 
text drawer. Long-running `EXPLAIN ANALYZE (FORMAT JSON)` can therefore log 
repeated errors instead of intermediate analyze output. It should either skip 
the intermediate logger in JSON mode or render through the JSON drawer.


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