aboutsummaryrefslogtreecommitdiff
path: root/python/pyspark/sql/tests.py
diff options
context:
space:
mode:
authorLiang-Chi Hsieh <viirya@appier.com>2015-07-19 00:32:56 -0700
committerReynold Xin <rxin@databricks.com>2015-07-19 00:32:56 -0700
commit9b644c41306cac53185ce0d2de4cb72127ada932 (patch)
treea4f15f2048fd1f02f912d34c22603b422ad80ae1 /python/pyspark/sql/tests.py
parent89d135851d928f9d7dcebe785c1b3b6a4d8dfc87 (diff)
downloadspark-9b644c41306cac53185ce0d2de4cb72127ada932.tar.gz
spark-9b644c41306cac53185ce0d2de4cb72127ada932.tar.bz2
spark-9b644c41306cac53185ce0d2de4cb72127ada932.zip
[SPARK-9166][SQL][PYSPARK] Capture and hide IllegalArgumentException in Python API
JIRA: https://issues.apache.org/jira/browse/SPARK-9166 Simply capture and hide `IllegalArgumentException` in Python API. Author: Liang-Chi Hsieh <viirya@appier.com> Closes #7497 from viirya/hide_illegalargument and squashes the following commits: 8324dce [Liang-Chi Hsieh] Fix python style. 9ace67d [Liang-Chi Hsieh] Also check exception message. 8b2ce5c [Liang-Chi Hsieh] Merge remote-tracking branch 'upstream/master' into hide_illegalargument 7be016a [Liang-Chi Hsieh] Capture and hide IllegalArgumentException in Python.
Diffstat (limited to 'python/pyspark/sql/tests.py')
-rw-r--r--python/pyspark/sql/tests.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/python/pyspark/sql/tests.py b/python/pyspark/sql/tests.py
index 241eac45cf..86706e2dc4 100644
--- a/python/pyspark/sql/tests.py
+++ b/python/pyspark/sql/tests.py
@@ -45,9 +45,9 @@ from pyspark.sql import SQLContext, HiveContext, Column, Row
from pyspark.sql.types import *
from pyspark.sql.types import UserDefinedType, _infer_type
from pyspark.tests import ReusedPySparkTestCase
-from pyspark.sql.functions import UserDefinedFunction
+from pyspark.sql.functions import UserDefinedFunction, sha2
from pyspark.sql.window import Window
-from pyspark.sql.utils import AnalysisException
+from pyspark.sql.utils import AnalysisException, IllegalArgumentException
class UTC(datetime.tzinfo):
@@ -894,6 +894,13 @@ class SQLTests(ReusedPySparkTestCase):
# RuntimeException should not be captured
self.assertRaises(py4j.protocol.Py4JJavaError, lambda: self.sqlCtx.sql("abc"))
+ def test_capture_illegalargument_exception(self):
+ self.assertRaisesRegexp(IllegalArgumentException, "Setting negative mapred.reduce.tasks",
+ lambda: self.sqlCtx.sql("SET mapred.reduce.tasks=-1"))
+ df = self.sqlCtx.createDataFrame([(1, 2)], ["a", "b"])
+ self.assertRaisesRegexp(IllegalArgumentException, "1024 is not in the permitted values",
+ lambda: df.select(sha2(df.a, 1024)).collect())
+
class HiveContextSQLTests(ReusedPySparkTestCase):