This is an automated email from the ASF dual-hosted git repository.
ruifengz 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 2a6ec83ba21 [SPARK-42077][CONNECT][PYTHON] Literal should throw
TypeError for unsupported DataType
2a6ec83ba21 is described below
commit 2a6ec83ba21aa4e1aed9c5f0bafc6724c2324e66
Author: Ruifeng Zheng <[email protected]>
AuthorDate: Mon Jan 16 13:14:26 2023 +0800
[SPARK-42077][CONNECT][PYTHON] Literal should throw TypeError for
unsupported DataType
### What changes were proposed in this pull request?
Make `Literal` throw TypeError for unsupported DataType
### Why are the changes needed?
Literal should throw TypeError for unsupported DataType
### Does this PR introduce _any_ user-facing change?
yes
### How was this patch tested?
updated UT
Closes #39588 from zhengruifeng/connect_lit_error.
Authored-by: Ruifeng Zheng <[email protected]>
Signed-off-by: Ruifeng Zheng <[email protected]>
---
python/pyspark/sql/connect/expressions.py | 4 ++--
python/pyspark/sql/tests/connect/test_connect_plan.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/python/pyspark/sql/connect/expressions.py
b/python/pyspark/sql/connect/expressions.py
index 5620b4e2cc6..d834b02eeaf 100644
--- a/python/pyspark/sql/connect/expressions.py
+++ b/python/pyspark/sql/connect/expressions.py
@@ -240,7 +240,7 @@ class LiteralExpression(Expression):
value = DayTimeIntervalType().toInternal(value)
assert value is not None
else:
- raise ValueError(f"Unsupported Data Type {dataType}")
+ raise TypeError(f"Unsupported Data Type {dataType}")
self._value = value
self._dataType = dataType
@@ -277,7 +277,7 @@ class LiteralExpression(Expression):
dt = _from_numpy_type(value.dtype)
if dt is not None:
return dt
- raise ValueError(f"Unsupported Data Type {type(value).__name__}")
+ raise TypeError(f"Unsupported Data Type {type(value).__name__}")
@classmethod
def _from_value(cls, value: Any) -> "LiteralExpression":
diff --git a/python/pyspark/sql/tests/connect/test_connect_plan.py
b/python/pyspark/sql/tests/connect/test_connect_plan.py
index 731160bd15d..7d9e88dff54 100644
--- a/python/pyspark/sql/tests/connect/test_connect_plan.py
+++ b/python/pyspark/sql/tests/connect/test_connect_plan.py
@@ -739,7 +739,7 @@ class SparkConnectPlanTests(PlanOnlyTestFixture):
def test_uuid_literal(self):
val = uuid.uuid4()
- with self.assertRaises(ValueError):
+ with self.assertRaises(TypeError):
lit(val)
def test_column_literals(self):
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]