LantaoJin opened a new pull request, #54: URL: https://github.com/apache/datafusion-java/pull/54
Closes #41 ## Which issue does this PR close? - Closes #41. ## Rationale for this change `DataFrame` gained `dropColumns` and `withColumnRenamed` in #30 but the most common column-shaping primitive -- adding or replacing a column from a SQL expression -- was still missing. `unnestColumns` is in the same family for struct / list flattening. The issue (#41) lists both as a single unit of work. `withColumn` and `unnestColumns` follow the same JNI shape as `filter(String)` from #19: the SQL fragment is parsed on the native side via `df.parse_sql_expr`, so no Java-side `Expr` model is required. That keeps this PR independent of any future joins / `Expr`-builder work. ## What changes are included in this PR? - `DataFrame.withColumn(String name, String expr)` — replaces a column of the same name in place, otherwise appends. Mirrors `DataFusion::DataFrame::with_column`. The expression is parsed against this DataFrame's own schema using the same `parse_sql_expr` convention as `filter(String)`. The receiver remains usable. - `DataFrame.unnestColumns(String... columns)` — defaults to upstream's `UnnestOptions::new()` (i.e. `preserve_nulls = true`). - `DataFrame.unnestColumns(UnnestOptions options, String... columns)` — explicit options overload. Routes to `unnest_columns_with_options` upstream. - `UnnestOptions` Java class with a single `preserveNulls(boolean)` knob (default `true`, matching upstream). - JNI handlers in `native/src/lib.rs`: `withColumnExpr` and `unnestColumns`. Both follow the existing patterns (`filterRows` / `dropColumns`) — no new imports beyond `datafusion::common::UnnestOptions`. Out of scope (filed separately): - `UnnestOptions.recursions` — needs a richer `RecursionUnnestOption` Java class with `input_column`, `output_column`, and `depth`, plus a parallel-array JNI layout. Not in #41's checklist; can land independently. ## Are these changes tested? Yes, 13 new tests, plus two existing close/collect tests extended. ## Are there any user-facing changes? Yes, purely additive. New public API: - `org.apache.datafusion.UnnestOptions` - `DataFrame.withColumn(String, String)` - `DataFrame.unnestColumns(String...)` - `DataFrame.unnestColumns(UnnestOptions, String...)` No API removals, no deprecations, no behavior change for existing callers. -- 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]
