gaborgsomogyi commented on a change in pull request #24403: [SPARK-23014][SS]
Fully remove V1 memory sink.
URL: https://github.com/apache/spark/pull/24403#discussion_r279366389
##########
File path: python/pyspark/sql/utils.py
##########
@@ -57,27 +58,41 @@ class QueryExecutionException(CapturedException):
"""
+class UnknownException(CapturedException):
+ """
+ None of the above exceptions.
+ """
+
+
+def convert_exception(e):
+ s = e.toString()
+ stackTrace = '\n\t at '.join(map(lambda x: x.toString(),
e.getStackTrace()))
+ c = e.getCause()
+ if s.startswith('org.apache.spark.sql.AnalysisException: '):
+ 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)
+ if s.startswith('org.apache.spark.sql.catalyst.parser.ParseException: '):
+ return ParseException(s.split(': ', 1)[1], stackTrace, c)
+ if s.startswith('org.apache.spark.sql.streaming.StreamingQueryException:
'):
+ return StreamingQueryException(s.split(': ', 1)[1], stackTrace, c)
+ if s.startswith('org.apache.spark.sql.execution.QueryExecutionException:
'):
+ return QueryExecutionException(s.split(': ', 1)[1], stackTrace, c)
+ if s.startswith('java.lang.IllegalArgumentException: '):
+ return IllegalArgumentException(s.split(': ', 1)[1], stackTrace, c)
+ return UnknownException(s, stackTrace, c)
+
+
def capture_sql_exception(f):
def deco(*a, **kw):
try:
return f(*a, **kw)
except py4j.protocol.Py4JJavaError as e:
- s = e.java_exception.toString()
- stackTrace = '\n\t at '.join(map(lambda x: x.toString(),
- e.java_exception.getStackTrace()))
- if s.startswith('org.apache.spark.sql.AnalysisException: '):
- raise AnalysisException(s.split(': ', 1)[1], stackTrace)
- if s.startswith('org.apache.spark.sql.catalyst.analysis'):
- raise AnalysisException(s.split(': ', 1)[1], stackTrace)
- if
s.startswith('org.apache.spark.sql.catalyst.parser.ParseException: '):
- raise ParseException(s.split(': ', 1)[1], stackTrace)
- if
s.startswith('org.apache.spark.sql.streaming.StreamingQueryException: '):
- raise StreamingQueryException(s.split(': ', 1)[1], stackTrace)
- if
s.startswith('org.apache.spark.sql.execution.QueryExecutionException: '):
- raise QueryExecutionException(s.split(': ', 1)[1], stackTrace)
- if s.startswith('java.lang.IllegalArgumentException: '):
- raise IllegalArgumentException(s.split(': ', 1)[1], stackTrace)
- raise
+ converted = convert_exception(e.java_exception)
+ if type(converted) is not UnknownException:
Review comment:
Yeah, I think it's more descriptive so changed.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]