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

   ### What changes were proposed in this pull request?
   
   This PR aims to support the error, reflection, and bitmap functions.
   
   | Function | Since |
   | -------- | ----- |
   | `assert_true(col)` / `assert_true(col, errMsg)` | 3.1.0 |
   | `raise_error(errMsg)` | 3.1.0 |
   | `reflect(cols...)` | 3.5.0 |
   | `java_method(cols...)` | 3.5.0 |
   | `try_reflect(cols...)` | 4.0.0 |
   | `bitmap_bit_position(col)` | 3.5.0 |
   | `bitmap_bucket_number(col)` | 3.5.0 |
   | `bitmap_count(col)` | 3.5.0 |
   
   All of them are classified as misc functions by PySpark and the Spark SQL 
Scala
   API, so they are added to the existing `MiscFunctions.swift` in alphabetical 
order.
   
   Two details follow the upstream implementations:
   
   - `errMsg` is `Union[Column, str]` in PySpark, where a `str` is wrapped with
     `lit()`. This is expressed as a `String` overload for `assert_true` and
     `raise_error`, like the existing `schema_of_json` overload pair.
   - The reflection functions are variadic. Their first argument is the class 
name,
     the second one is the method name, and the remaining ones are the method
     arguments. No `String` overload is added for them because a bare string is 
a
     column name rather than a literal in PySpark, so an overload would silently
     mean the opposite of the upstream API.
   
   Since the reflection functions invoke an arbitrary Java static method on the
   server, their doc comments note that the class must be on the Spark server's
   classpath and that the class and the method names must never be built from
   untrusted user input.
   
   ### Why are the changes needed?
   
   To improve the API coverage. These functions are available in PySpark and the
   Spark SQL Scala API, but were missing from this Swift client.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No, this is a new feature.
   
   ```swift
   try await spark.range(1).select(
     reflect(lit("java.util.UUID"), lit("fromString"), 
lit("a5cf6c42-0c85-418f-af6c-3e4e5b1328f2")),
     bitmap_bit_position(lit(123)),
     bitmap_bucket_number(lit(123)),
     bitmap_count(unhex(lit("FFFF")))
   ).show()
   ```
   
   ```
   
+-------------------------------------------------------------------------+------------------------+-------------------------+-------------------------+
   |reflect(java.util.UUID, fromString, 
a5cf6c42-0c85-418f-af6c-3e4e5b1328f2)|bitmap_bit_position(123)|bitmap_bucket_number(123)|bitmap_count(unhex(FFFF))|
   
+-------------------------------------------------------------------------+------------------------+-------------------------+-------------------------+
   |                                                     a5cf6c42-0c85-418...|  
                   122|                        1|                       16|
   
+-------------------------------------------------------------------------+------------------------+-------------------------+-------------------------+
   ```
   
   ### How was this patch tested?
   
   Pass the CIs with the new test cases in `MiscFunctionsTests`.
   
   ### 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