dongjoon-hyun commented on code in PR #60215:
URL: https://github.com/apache/spark/pull/60215#discussion_r4521555305
##########
python/pyspark/sql/tests/streaming/test_streaming.py:
##########
@@ -333,11 +333,17 @@ def test_stream_await_termination(self):
)
try:
self.assertTrue(q.isActive)
- try:
+ with self.assertRaises(PySparkTypeError) as pe:
Review Comment:
Since the type check is split out now, `"hello"` no longer reaches the
`VALUE_NOT_POSITIVE` branch, so that branch is not covered by this test (and
`test_query_manager_await_termination`) anymore. Could you add a
negative-timeout case to keep it covered for both Classic and Connect? For
example,
```python
with self.assertRaises(PySparkValueError):
q.awaitTermination(-1)
```
##########
python/pyspark/sql/streaming/query.py:
##########
@@ -217,7 +217,16 @@ def awaitTermination(self, timeout: Optional[int] = None)
-> Optional[bool]:
>>> sq.stop()
"""
if timeout is not None:
- if not isinstance(timeout, (int, float)) or timeout <= 0:
+ if not isinstance(timeout, (int, float)):
Review Comment:
nit. This `NOT_EXPECTED_TYPE` block is now duplicated in four places (two
here and two in `connect/streaming/query.py`). Since the Connect module already
imports from `pyspark.sql.streaming.query`, shall we extract a small shared
helper to keep them in sync?
##########
python/pyspark/sql/streaming/query.py:
##########
@@ -217,7 +217,16 @@ def awaitTermination(self, timeout: Optional[int] = None)
-> Optional[bool]:
>>> sq.stop()
"""
if timeout is not None:
- if not isinstance(timeout, (int, float)) or timeout <= 0:
+ if not isinstance(timeout, (int, float)):
+ raise PySparkTypeError(
+ errorClass="NOT_EXPECTED_TYPE",
+ messageParameters={
+ "arg_name": "timeout",
+ "expected_type": "int or float",
Review Comment:
nit. The existing `NOT_EXPECTED_TYPE` errors for the same types use `"float
or int"` (e.g., `classic/dataframe.py` and `connect/dataframe.py`). Shall we
use the same wording here and in the other three places?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]