You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "dongjoon-hyun (via GitHub)" <gi...@apache.org> on 2026/09/12 23:37:17 UTC
[PR] [SPARK-59462] Support safe upcasts and throw errors instead of crashing in `DataFrame.collect(as:)` [spark-connect-swift]
dongjoon-hyun opened a new pull request, #553:
URL: https://github.com/apache/spark-connect-swift/pull/553
### What changes were proposed in this pull request?
This PR aims to throw `ArrowError.invalid` instead of crashing in `DataFrame.collect(as:)` when a value cannot be decoded into the target Swift type. It also allows Scala-style safe numeric upcasts (a narrower signed integer into a wider one, and `Float` into `Double`).
```swift
// Upcast: INT -> Int64
try await spark.sql("SELECT 30 AS age").collect(as: Int64.self)
// Throws ArrowError.invalid("Cannot decode Int32 for column 0")
try await spark.sql("SELECT 30L AS age").collect(as: Int32.self)
```
### Why are the changes needed?
`ArrowDecoder` force-unwraps decoded values and converts signed values with `UInt(val)`. As a result, a type mismatch, a `NULL` value, or a negative value into `UInt` crashes the whole process.
```swift
spark.sql("SELECT CAST(NULL AS STRING) AS name, 1L AS age").collect(as: Person.self)
// Fatal error: Unexpectedly found nil while unwrapping an Optional value
```
### Does this PR introduce _any_ user-facing change?
No for the released versions because `DataFrame.collect(as:)` exists only in the `main` branch.
### How was this patch tested?
Pass the CIs with the newly added test cases.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5
--
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-59462] Support safe upcasts and throw errors instead of crashing in `DataFrame.collect(as:)` [spark-connect-swift]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #553:
URL: https://github.com/apache/spark-connect-swift/pull/553#issuecomment-5650940326
Merged to main
--
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-59462] Support safe upcasts and throw errors instead of crashing in `DataFrame.collect(as:)` [spark-connect-swift]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun closed pull request #553: [SPARK-59462] Support safe upcasts and throw errors instead of crashing in `DataFrame.collect(as:)`
URL: https://github.com/apache/spark-connect-swift/pull/553
--
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-59462] Support safe upcasts and throw errors instead of crashing in `DataFrame.collect(as:)` [spark-connect-swift]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #553:
URL: https://github.com/apache/spark-connect-swift/pull/553#issuecomment-5650934905
Thank you, @viirya ~
--
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