HyukjinKwon commented on a change in pull request #28661: URL: https://github.com/apache/spark/pull/28661#discussion_r431637708
########## File path: python/pyspark/sql/utils.py ########## @@ -75,21 +96,29 @@ class UnknownException(CapturedException): def convert_exception(e): s = e.toString() - stackTrace = '\n\t at '.join(map(lambda x: x.toString(), e.getStackTrace())) c = e.getCause() + + jvm = SparkContext._jvm + jwriter = jvm.java.io.StringWriter() + e.printStackTrace(jvm.java.io.PrintWriter(jwriter)) + stacktrace = jwriter.toString() if s.startswith('org.apache.spark.sql.AnalysisException: '): - return AnalysisException(s.split(': ', 1)[1], stackTrace, c) + return AnalysisException(s.split(': ', 1)[1], stacktrace, c) if s.startswith('org.apache.spark.sql.catalyst.analysis'): - return AnalysisException(s.split(': ', 1)[1], stackTrace, c) + return AnalysisException(s.split(': ', 1)[1], stacktrace, c) if s.startswith('org.apache.spark.sql.catalyst.parser.ParseException: '): - return ParseException(s.split(': ', 1)[1], stackTrace, c) + return ParseException(s.split(': ', 1)[1], stacktrace, c) Review comment: I think `ParseException` at least shows a meaningful error message to the end user such as: ``` : org.apache.spark.sql.catalyst.parser.ParseException: mismatched input 'a' expecting {'(', 'ADD', 'ALTER', 'ANALYZE', 'CACHE', 'CLEAR', 'COMMENT', 'COMMIT', 'CREATE', 'DELETE', 'DESC', 'DESCRIBE', 'DFS', 'DROP', 'EXPLAIN', 'EXPORT', 'FROM', 'GRANT', 'IMPORT', 'INSERT', 'LIST', 'LOAD', 'LOCK', 'MAP', 'MERGE', 'MSCK', 'REDUCE', 'REFRESH', 'REPLACE', 'RESET', 'REVOKE', 'ROLLBACK', 'SELECT', 'SET', 'SHOW', 'START', 'TABLE', 'TRUNCATE', 'UNCACHE', 'UNLOCK', 'UPDATE', 'USE', 'VALUES', 'WITH'}(line 1, pos 0) == SQL == a ^^^ ``` If developers want to debug, they can enable `spark.sql.pyspark.jvmStacktrace.enabled`. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org