cj-zhukov opened a new pull request, #25299: URL: https://github.com/apache/datafusion/pull/25299
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Closes #https://github.com/apache/datafusion/issues/25298. ## Rationale for this change `DataFrame::with_column` only adds an `Expr`. Appending an `ArrayRef` today means collecting the frame, concatenating columns, and calling `read_batch`. That executes the plan just to change the schema. Related https://github.com/apache/datafusion/issues/9672 This PR adds a lazy API for that case: the array is stored on the plan and attached when the new `DataFrame` runs. No collect at the call site. ```rust let df = DataFrame::from_columns([("id", id), ("data", data)])?; let df = df.with_array_columns([("new_col", new_col)])?; let df = df.filter(col("id").gt(lit(1)))?; df.collect().await?; ``` ## What changes are included in this PR? - `DataFrame::with_array_columns` - same shape as `from_columns` (name + `ArrayRef`). - `AddColumnProvider` (`TableProvider`) wraps the current `LogicalPlan` and the new columns. - `AddColumnExec` (`ExecutionPlan`) zips each input batch with `array.slice(offset, n)` at execution time. ## What is the testing strategy for this PR? Yes. Tests cover: - appending a column and collecting - filter / select after append (still lazy) - length mismatch at execution - duplicate column name ## Are there any user-facing changes? Yes - new `DataFrame::with_array_columns` method. Not a breaking change. Docs and an example are included. -- 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]
