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

   ### What changes were proposed in this pull request?
   
   This PR aims to support `withField` and `dropFields` in `Column`.
   
   ```swift
   // {"a":1,"b":2,"c":3} -> {"a":1,"b":20,"c":3}
   df.select(col("s").withField("b", lit(20)))
   
   // {"a":1,"b":2,"c":3} -> {"a":1}
   df.select(col("s").dropFields("b", "c"))
   
   // Nested fields: {"a":{"a":1,"b":2}} -> {"a":{"a":1}}
   df.select(col("s").dropFields("a.b"))
   ```
   
   Both methods are built on the existing `Expression.UpdateFields` proto, 
following PySpark Connect.
   - `withField` sets `struct_expression`, `field_name`, and `value_expression`.
   - `dropFields` leaves `value_expression` unset, because the server treats an 
unset value expression as a drop. Multiple field names are nested in order, 
like `update_fields(update_fields(s, b), c)`.
   
   `dropFields` requires at least one field name through its signature, 
`dropFields(_ fieldName: String, _ fieldNames: String...)`, so an empty call is 
rejected at compile time instead of at runtime.
   
   ### Why are the changes needed?
   
   For feature parity with PySpark, which has supported `Column.withField` and 
`Column.dropFields` since Apache Spark 3.1.0 and Spark Connect since 3.4.0. 
These APIs let users add, replace, or drop fields of struct columns, including 
nested fields.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, this PR adds two new public APIs, `Column.withField` and 
`Column.dropFields`.
   
   ### 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]

Reply via email to