cloud-fan opened a new pull request, #54554:
URL: https://github.com/apache/spark/pull/54554

   ### What changes were proposed in this pull request?
   
   Add a `--DEBUG` marker directive for the SQL golden file test framework 
(`SQLQueryTestSuite`). When placed on its own line before a query in an input 
`.sql` file, it enables a focused debug mode:
   
   - **Selective execution**: Only `--DEBUG`-marked queries and setup commands 
(CREATE TABLE, INSERT, SET, etc.) are executed; all other queries are skipped.
   - **Full error details**: Failed queries print the complete stacktrace to 
the console.
   - **Golden comparison**: Results are still compared against the golden file 
so you can verify correctness.
   - **Safety net**: The test always fails at the end with a reminder to remove 
`--DEBUG` markers before committing.
   - **DataFrame access**: Documentation guides users to set a breakpoint in 
`runDebugQueries` to inspect the `DataFrame` instance for ad-hoc plan analysis.
   
   Example usage in an input file:
   ```sql
   CREATE TABLE t (id INT, val INT) USING parquet;
   INSERT INTO t VALUES (1, 10), (2, 20);
   -- this query is skipped in debug mode
   SELECT count(*) FROM t;
   -- this is the query I'm debugging
   --DEBUG
   SELECT sum(val) OVER (ORDER BY id) FROM t;
   ```
   
   ### Why are the changes needed?
   
   Debugging golden file test failures is currently painful:
   1. You must run all queries even if only one needs debugging.
   2. Error output is minimal (just the error class/message), with no 
stacktrace.
   3. There is no way to access the `DataFrame` instance for plan inspection.
   
   This change addresses all three issues with a simple, zero-config marker 
that can be temporarily added during development.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. This is a test infrastructure improvement only.
   
   ### How was this patch tested?
   
   - Manually tested with `--DEBUG` markers on both passing and failing queries 
in `inline-table.sql`.
   - Verified backward compatibility: tests pass normally when no `--DEBUG` 
markers are present.
   - Verified debug mode output includes full stacktraces, golden answer 
comparison, and the safety-fail message.


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to