urosstan-db opened a new pull request, #59466: URL: https://github.com/apache/spark/pull/59466
### What changes were proposed in this pull request? Allow `vector_sum` to accept `ARRAY<DOUBLE>` as well as `ARRAY<FLOAT>`, returning an array with the same element type as its input. Use type-specific accessors for the aggregate buffer and update the SQL, Scala, and PySpark documentation. This PR is a draft pending a SPARK Jira ticket. ### Why are the changes needed? Double-valued vectors currently require conversion to floats before aggregation, which loses precision and limits the representable range. Supporting doubles allows sums such as `16777216.0D + 1.0D` to retain the result `16777217.0`. ### Does this PR introduce _any_ user-facing change? Yes. `vector_sum` now accepts double arrays, which previously raised a type mismatch error, and accumulates them in double precision. For example: ```sql SELECT vector_sum(v) FROM VALUES (array(16777216.0D)), (array(1.0D)) AS t(v); ``` The result is an `ARRAY<DOUBLE>` containing `16777217.0`. Float inputs retain their existing result type and behavior. The other vector functions continue to accept only float arrays. ### How was this patch tested? Added `VectorAggSuite` coverage for double precision, buffer updates and merges, result types, nulls, empty arrays, special values, dimension mismatches, and unsupported input types. Extended `vector-agg.sql` with double-input aggregation and window queries. Validated with Java 17: - `build/sbt 'catalyst/testOnly *VectorAggSuite'`: all 57 tests passed. - Regenerated the execution and analyzer golden files with `SPARK_GENERATE_GOLDEN_FILES=1 build/sbt 'sql/testOnly *SQLQueryTestSuite -- -z vector-agg.sql'`, reviewed the diff, and reran without regeneration: both tests passed. - `build/sbt 'catalyst/Compile/scalastyle' 'catalyst/Test/scalastyle' 'sql-api/Compile/scalastyle'`: passed with no errors or warnings. - Python syntax and `git diff --check`: passed. ### 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]
