dongjoon-hyun opened a new pull request, #564: URL: https://github.com/apache/spark-connect-swift/pull/564
### What changes were proposed in this pull request? This PR aims to fix `DataFrame.head()` and `first()` to throw `SparkConnectError.invalidState` instead of crashing on empty results. ### Why are the changes needed? Currently, `head()` and `first()` crash on an empty `DataFrame`. ```swift try await spark.range(0).head() // Fatal error: Index out of range ``` Apache Spark's `Dataset.head()` throws `NoSuchElementException: head of empty array` in this case ([v4.2.0](https://github.com/apache/spark/blob/v4.2.0/sql/api/src/main/scala/org/apache/spark/sql/Dataset.scala#L2786), 2026-07-11). This PR uses the same message. ### Does this PR introduce _any_ user-facing change? No behavior change. Previously, `head()` and `first()` crashes and now they throw an error on an empty `DataFrame` . Both methods are already `async throws`, so this is source-compatible. ### 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: [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]
