From 273c1bc8d719158dd074cb806d5db487b9709edb Mon Sep 17 00:00:00 2001 From: uncleGen Date: Sun, 12 Mar 2017 20:57:31 +0800 Subject: [PATCH 1/3] Make pyspark exception more readable --- python/pyspark/sql/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pyspark/sql/utils.py b/python/pyspark/sql/utils.py index 7bc6a59ad3b26..8d6c81bc9490a 100644 --- a/python/pyspark/sql/utils.py +++ b/python/pyspark/sql/utils.py @@ -24,7 +24,7 @@ def __init__(self, desc, stackTrace): self.stackTrace = stackTrace def __str__(self): - return repr(self.desc) + return str(self.desc) class AnalysisException(CapturedException): From 7b96e97b60b67cab49f3108ad84759ccb0f643e0 Mon Sep 17 00:00:00 2001 From: uncleGen Date: Tue, 14 Mar 2017 12:29:29 +0800 Subject: [PATCH 2/3] address comments from @HyukjinKwon --- python/pyspark/sql/utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/python/pyspark/sql/utils.py b/python/pyspark/sql/utils.py index 8d6c81bc9490a..f35b4a31b2017 100644 --- a/python/pyspark/sql/utils.py +++ b/python/pyspark/sql/utils.py @@ -16,6 +16,10 @@ # import py4j +import sys + +if sys.version > '3': + unicode = str class CapturedException(Exception): @@ -24,7 +28,11 @@ def __init__(self, desc, stackTrace): self.stackTrace = stackTrace def __str__(self): - return str(self.desc) + desc = self.desc + if isinstance(desc, unicode): + return str(desc.encode('utf-8')) + else: + return str(desc) class AnalysisException(CapturedException): From edf9b12d29a4809beed030e6844b0aa1fede3ef5 Mon Sep 17 00:00:00 2001 From: uncleGen Date: Tue, 14 Mar 2017 17:26:08 +0800 Subject: [PATCH 3/3] bug fix --- python/pyspark/sql/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pyspark/sql/utils.py b/python/pyspark/sql/utils.py index f35b4a31b2017..8e04943294653 100644 --- a/python/pyspark/sql/utils.py +++ b/python/pyspark/sql/utils.py @@ -18,7 +18,7 @@ import py4j import sys -if sys.version > '3': +if sys.version >= '3': unicode = str