This is an automated email from the ASF dual-hosted git repository.
gurwls223 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 6337412973a [SPARK-46296][PYTHON][TESTS] Test missing test coverage
for captured errors (pyspark.errors.exceptions)
6337412973a is described below
commit 6337412973af9431502d411679525c518214457a
Author: Hyukjin Kwon <[email protected]>
AuthorDate: Thu Dec 7 13:32:31 2023 +0900
[SPARK-46296][PYTHON][TESTS] Test missing test coverage for captured errors
(pyspark.errors.exceptions)
### What changes were proposed in this pull request?
This PR adds tests for negative cases of `getErrorClass` and `getSqlState`.
And test case for `getMessageParameters` for errors.
### Why are the changes needed?
To improve the test coverage.
See
https://app.codecov.io/gh/apache/spark/commit/1a651753f4e760643d719add3b16acd311454c76/blob/python/pyspark/errors/exceptions/captured.py
This is not being tested.
### Does this PR introduce _any_ user-facing change?
No, test-only
### How was this patch tested?
Manually ran the new unittest.
### Was this patch authored or co-authored using generative AI tooling?
Np.
Closes #44224 from HyukjinKwon/SPARK-46296.
Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
---
python/pyspark/errors/exceptions/captured.py | 2 +-
python/pyspark/sql/tests/test_utils.py | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/python/pyspark/errors/exceptions/captured.py
b/python/pyspark/errors/exceptions/captured.py
index df23be8a979..ec987e0854e 100644
--- a/python/pyspark/errors/exceptions/captured.py
+++ b/python/pyspark/errors/exceptions/captured.py
@@ -104,7 +104,7 @@ class CapturedException(PySparkException):
if self._origin is not None and is_instance_of(
gw, self._origin, "org.apache.spark.SparkThrowable"
):
- return self._origin.getMessageParameters()
+ return dict(self._origin.getMessageParameters())
else:
return None
diff --git a/python/pyspark/sql/tests/test_utils.py
b/python/pyspark/sql/tests/test_utils.py
index b99ca41e84f..f633837002e 100644
--- a/python/pyspark/sql/tests/test_utils.py
+++ b/python/pyspark/sql/tests/test_utils.py
@@ -1749,6 +1749,14 @@ class UtilsTests(ReusedSQLTestCase, UtilsTestsMixin):
except AnalysisException as e:
self.assertEqual(e.getErrorClass(),
"UNRESOLVED_COLUMN.WITHOUT_SUGGESTION")
self.assertEqual(e.getSqlState(), "42703")
+ self.assertEqual(e.getMessageParameters(), {"objectName": "`a`"})
+
+ try:
+ self.spark.sql("""SELECT assert_true(FALSE)""")
+ except AnalysisException as e:
+ self.assertIsNone(e.getErrorClass())
+ self.assertIsNone(e.getSqlState())
+ self.assertEqual(e.getMessageParameters(), {})
if __name__ == "__main__":
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]