You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "xinrong-meng (via GitHub)" <gi...@apache.org> on 2025/09/02 17:59:14 UTC
Re: [PR] [SPARK-53441][PS] Bools `|`/`&`/`^` None should fail under ANSI [spark]
xinrong-meng commented on code in PR #52182:
URL: https://github.com/apache/spark/pull/52182#discussion_r2316793513
##########
python/pyspark/pandas/data_type_ops/boolean_ops.py:
##########
@@ -237,6 +237,12 @@ def rmod(self, left: IndexOpsLike, right: Any) -> SeriesOrIndex:
def __and__(self, left: IndexOpsLike, right: Any) -> SeriesOrIndex:
_sanitize_list_like(right)
+ if (
+ is_ansi_mode_enabled(left._internal.spark_frame.sparkSession)
+ and self.dtype == bool
Review Comment:
We need to check `self.dtype == bool` because
```py
>>> pd.Series([True, False, np.nan]) | None
0 False
1 False
2 False
>>> ps.Series([True, False, np.nan]).dtype
dtype('O')
>>> ps.Series([True, False, np.nan]).spark.data_type
BooleanType()
```
`BooleanType()` will direct the code path here, but we want to support (instead of TypeError) this case, so we check `dtype` explicitly
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org