Skip to content

Conversation

@srielau
Copy link
Contributor

@srielau srielau commented Jan 2, 2026

What changes were proposed in this pull request?

Two changes in this pull request:

  • Suppress stack trace information fro spark-sql CLI with PRETTY error format, unless the error is internal. Prior to this stack trace was suppressed only for AnalysisException
  • Introduce a new DEBUG error format which matches PRETTY + always dumping the stack (if available).

Why are the changes needed?

This makes the experience of using CLI much more consistent without losing capability. It also clearly seperates "consumer" output, from developer output.

Does this PR introduce any user-facing change?

Yes, in CLI error message output is by default more consistent.

How was this patch tested?

Added new tests

Was this patch authored or co-authored using generative AI tooling?

Claude

@github-actions
Copy link

github-actions bot commented Jan 2, 2026

JIRA Issue Information

=== Improvement SPARK-54883 ===
Summary: Make error messages in CLI (spark-sql) more consistent
Assignee: None
Status: Open
Affected: ["4.2.0"]


This comment was automatically generated by GitHub Actions

@github-actions github-actions bot added the SQL label Jan 2, 2026
@srielau srielau marked this pull request as draft January 2, 2026 01:42
@srielau srielau changed the title Clean up error messages for CLI and add new error mode DEBUG [WIP][MINOR] Clean up error messages for CLI and add new error mode DEBUG Jan 2, 2026
@srielau srielau changed the title [WIP][MINOR] Clean up error messages for CLI and add new error mode DEBUG [SPARK-54883][MINOR] Clean up error messages for CLI and add new error mode DEBUG Jan 2, 2026
@srielau srielau marked this pull request as ready for review January 2, 2026 05:49
// - DEBUG format: Always print stack traces (for debugging)
// - PRETTY format: Only for internal errors (SQLSTATE XX***)
// - MINIMAL/STANDARD formats: Never print stack traces (JSON only)
val shouldPrintStackTrace = format match {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QQ: is the change for spark-sql only? What about spark-shell and pyspark?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, shall we add document in https://spark.apache.org/docs/latest/sql-migration-guide.html#upgrading-from-spark-sql-40-to-41 for the behavior change and the configuration to restore the old behavior?

Copy link
Contributor Author

@srielau srielau Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gengliangwang Right now only spark-sql. If there is a desire I can extend it (with some pointers). But for spark-shell its a bit more invasive. I think we always return a stack trace (?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, on second thought, the inconsistency seems reasonable.
However, the new log format DEBUG seems only working for spark-sql, instead of all other CLI and applications. Shall we simply introduce a new configuration for the log output of spark-sql?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, on second thought, the inconsistency seems reasonable. However, the new log format DEBUG seems only working for spark-sql, instead of all other CLI and applications. Shall we simply introduce a new configuration for the log output of spark-sql?

Good point I think it woudl be nice to have it generally.

@gengliangwang
Copy link
Member

+1 for making the output of spark-sql simpler.
cc @cloud-fan @dongjoon-hyun @yaooqinn @HyukjinKwon WDYT?

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 9d81260 Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants