GaneshPatil7517 opened a new pull request, #19791: URL: https://github.com/apache/datafusion/pull/19791
## Which issue does this PR close? Closes #18150 Fixes #18149 ## Rationale for this change The previous implementation called `try_plan_async_exprs()` at three separate locations (projection, filter, aggregation), each with its own match arms handling `PlanAsyncExpr::Sync` vs `PlanAsyncExpr::Async`. This caused: 1. **Duplication** - The same pattern repeated three times 2. **Cognitive overhead** - Understanding async UDF handling required reading all three locations 3. **Bug #18149** - Aggregation passed the wrong schema to `AggregateExec`, causing expression/schema mismatch ## What changes are included in this PR? Introduces two helper methods that consolidate async UDF handling: - `maybe_wrap_async_exec()` — for plain expressions (filter, aggregation) - `maybe_wrap_async_exec_with_names()` — for projection expressions with aliases Both methods: 1. Scan expressions for async UDFs 2. If found, wrap the input with `AsyncFuncExec` 3. Return the (possibly wrapped) input and rewritten expressions This makes each call site a simple function call instead of a multi-arm match. ### Removed code - `try_plan_async_exprs()` method - `PlannedExprResult` enum - `PlanAsyncExpr` enum ### How this fixes #18149 The bug occurred because aggregation expressions were rewritten to reference `__async_fn_0@N`, but `AggregateExec` was created with the original schema (which didn't include async columns). The fix uses `input_exec.schema()` after wrapping with `AsyncFuncExec`, ensuring the aggregate sees a schema that includes the async columns. ## Are these changes tested? Existing `async_udf.slt` tests cover async UDF usage in projections, filters, and aggregations. Physical plan outputs remain unchanged. ## Are there any user-facing changes? No. This is an internal refactor with no public API changes. -- 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]
