zhengruifeng opened a new pull request, #60224:
URL: https://github.com/apache/spark/pull/60224

   ### What changes were proposed in this pull request?
   
   Add `VectorToArray` under Catalyst's ML expressions and use it in 
`InternalFunctionRegistration` in place of the two Scala UDFs. The expression 
accepts a vector SQL struct or any UDT with the matching underlying SQL type, 
and produces an array of doubles or floats. Interpreted and generated 
evaluation operate directly on Catalyst rows and arrays.
   
   ### Why are the changes needed?
   
   The UDF implementation deserializes vector objects and limits inputs to the 
ML and MLlib vector classes. A dedicated expression supports their SQL 
representation directly and validates input types during analysis.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. `vector_to_array` also accepts matching SQL structs and UDTs. Invalid 
input types fail during analysis, and default output column names reflect the 
ML expression instead of `UDF`. Null inputs remain rejected; output arrays and 
their elements remain non-nullable.
   
   ### How was this patch tested?
   
   Compiled the changed Java and Scala sources against locally cached Spark 
jars and ran:
   
   - `VectorToArraySuite`: all 5 tests passed, including interpreted and 
generated evaluation, both output types, dense/sparse/empty vectors, matching 
UDTs, special values, and invalid inputs.
   - `FunctionsSuite` filtered by `vector_to_array`: both tests passed, 
covering ML and MLlib UDTs, SQL structs, registration, output schema, nulls, 
and invalid types.
   - Scalastyle on all 4 changed Scala files: passed.
   - Checkstyle on `MLExpressionUtils.java`: passed.
   - `git diff --check`: passed.
   
   The normal SBT test invocation was attempted but could not load the project 
because Maven dependency hosts could not be resolved. The focused tests above 
used the local compiler and ScalaTest runner with cached Spark dependencies.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: OpenAI Codex (GPT-6)
   


-- 
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