Repository navigation
Expand scalar async UDF results to the batch row count - #25828
Conversation
| // scalar applies to every row, so it must be expanded to the number of rows in | ||
| // each chunk rather than to a single row. | ||
| #[tokio::test] | ||
| async fn test_async_udf_with_scalar_result() -> Result<()> { |
There was a problem hiding this comment.
Without the fix fails with:
Error: ArrowError(InvalidArgumentError("all columns in a record batch must have the same length"), Some(""))
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #25828 +/- ##
==========================================
- Coverage 82.59% 82.59% -0.01%
==========================================
Files 1144 1144
Lines 441854 441849 -5
Branches 441854 441849 -5
==========================================
- Hits 364965 364951 -14
- Misses 54809 54815 +6
- Partials 22080 22083 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
xanderbailey
left a comment
There was a problem hiding this comment.
Verified that the test fails before the fix. Thanks @hareshkh great find!
Jefffrey
left a comment
There was a problem hiding this comment.
its unfortunate that we cant exactly reap the benefits of ColumnarValue::Scalar here and are always forced to expand to arrays, though with how this code is structured (compared to its sync counterpart) i suppose it might be hard to do without a wider refactor
fix makes sense, thanks for the ping 👍
|
thanks @hareshkh & @xanderbailey |
## Which issue does this PR close? - Closes apache#25875 ## Rationale for this change When an async UDF returns a `ColumnarValue::Scalar` (e.g. all arguments are literals), queries on more than one row fail with `all columns in a record batch must have the same length`. ## What changes are included in this PR? `AsyncFuncExpr::invoke_with_args` expands each result to its chunk's row count via `into_array_of_size`, instead of turning a scalar into a 1-row array. ## What is the testing strategy for this PR? Added `test_async_udf_with_scalar_result` in `user_defined_async_scalar_functions.rs`. It fails without the fix. ## Are there any user-facing changes? No.
…25828) (#27372) - Backport of #25828 to `branch-54` - Part of #23805 Co-authored-by: Haresh Khanna <[email protected]>
…25828) (#27373) - Backport of #25828 to `branch-55` - Part of #26868 Co-authored-by: Haresh Khanna <[email protected]>
Which issue does this PR close?
Rationale for this change
When an async UDF returns a
ColumnarValue::Scalar(e.g. all arguments are literals), queries on more than one row fail withall columns in a record batch must have the same length.What changes are included in this PR?
AsyncFuncExpr::invoke_with_argsexpands each result to its chunk's row count viainto_array_of_size, instead of turning a scalar into a 1-row array.What is the testing strategy for this PR?
Added
test_async_udf_with_scalar_resultinuser_defined_async_scalar_functions.rs. It fails without the fix.Are there any user-facing changes?
No.