You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "Yicong-Huang (via GitHub)" <gi...@apache.org> on 2026/01/29 00:00:35 UTC
[PR] [SPARK-54943][PYTHON][TESTS] Add test coverage for pa.Array.cast with safe=False [spark]
Yicong-Huang opened a new pull request, #54047:
URL: https://github.com/apache/spark/pull/54047
### What changes were proposed in this pull request?
This PR extends the PyArrow array cast tests to cover both `safe=True` and `safe=False` behaviors in each test case.
Changes:
1. **Modified `_run_cast_tests` method**: Now tests both `safe=True` and `safe=False` modes for each test case
2. **Extended test case format**: Support 3-tuple format `(src_arr, expected_safe_true, expected_safe_false)` where `expected_safe_false=None` means same behavior as `safe=True`
3. **Updated 200+ test cases**: All overflow/truncation cases now explicitly specify the `safe=False` behavior (wrapping, truncation, or saturation)
Categories of `safe=False` behavior covered:
- **Integer overflow**: Negative-to-unsigned wraps (e.g., `-1` → `255` for uint8)
- **Integer narrowing**: Value wraps on overflow (e.g., `128` as int16 → `-128` as int8)
- **Float-to-integer**: Truncation and saturation for out-of-range values
- **Timestamp/Duration precision loss**: Truncation when casting to coarser units
- **Decimal overflow**: Wrapping behavior for values exceeding integer limits
### Why are the changes needed?
The existing tests only covered `safe=True` behavior. This PR adds comprehensive coverage for `safe=False` to ensure PySpark correctly handles PyArrow's overflow/truncation semantics, which is important for data processing pipelines that need to handle edge cases gracefully.
Part of [SPARK-54936](https://issues.apache.org/jira/browse/SPARK-54936)
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
All 39 tests in `PyArrowNumericalCastTests` pass with the updated test framework.
### Was this patch authored or co-authored using generative AI tooling?
Yes
--
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
Re: [PR] [SPARK-54943][PYTHON][TESTS] Add test coverage for pa.Array.cast with safe=False [spark]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #54047:
URL: https://github.com/apache/spark/pull/54047#issuecomment-3814565407
## JIRA Issue Information
=== Sub-task SPARK-54943 ===
Summary: Add tests for pa.Array.cast with overflow
Assignee: Yicong Huang
Status: Resolved
Affected: ["4.2.0"]
---
*This comment was automatically generated by GitHub Actions*
--
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
Re: [PR] [SPARK-54943][PYTHON][TESTS] Add test coverage for pa.Array.cast with safe=False [spark]
Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on PR #54047:
URL: https://github.com/apache/spark/pull/54047#issuecomment-3815143211
disabling it in https://github.com/apache/spark/pull/54049
--
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
Re: [PR] [SPARK-54943][PYTHON][TESTS] Add test coverage for pa.Array.cast with safe=False [spark]
Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on PR #54047:
URL: https://github.com/apache/spark/pull/54047#issuecomment-3814976403
@Yicong-Huang this PR fails almost all scheduled jobs, e.g. https://github.com/apache/spark/actions/runs/21453536990/job/61788451084
--
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
Re: [PR] [SPARK-54943][PYTHON][TESTS] Add test coverage for pa.Array.cast with safe=False [spark]
Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang closed pull request #54047: [SPARK-54943][PYTHON][TESTS] Add test coverage for pa.Array.cast with safe=False
URL: https://github.com/apache/spark/pull/54047
--
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