dongjoon-hyun opened a new pull request, #467:
URL: https://github.com/apache/spark-connect-swift/pull/467

   ### What changes were proposed in this pull request?
   
   This PR aims to support field-name-based access in `Row` like Scala's 
`GenericRowWithSchema`.
   
   - A new `RowSchema` class holds the field names and a name-to-index 
dictionary, shared by reference across all `Row`s of the same batch.
   - `Row` gains `fieldIndex(_:)`, `get(_ name:)`, `subscript(name:)`, and 
`asDict()`. For duplicate field names, the last one wins like Scala.
   - `DataFrame.collect()` attaches a `RowSchema` created from the Arrow schema 
to every `Row`.
   
   ### Why are the changes needed?
   
   Previously, `Row` only supported position-based access. This provides the 
equivalent of PySpark's `row["name"]`/`asDict()` and Scala's `fieldIndex(name)`.
   
   ```swift
   let rows = try await spark.sql("SELECT * FROM VALUES (1, 'abc') T(id, 
name)").collect()
   let id = try rows[0].get("id") as! Int32
   let name = try rows[0]["name"] as! String
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, this adds new public APIs. All existing APIs and behaviors are 
unchanged.
   
   ### How was this patch tested?
   
   Pass the CIs with newly added test cases.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Fable 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]

Reply via email to