| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Closes apache#41 withColumn(name, expr) takes a SQL fragment, parses it via df.parse_sql_expr (the same convention filter(String) uses), and calls DataFusion's with_column. Replaces a column of the same name in place; otherwise appends. unnestColumns(String...) and unnestColumns(UnnestOptions, String...) route to unnest_columns_with_options. UnnestOptions exposes the preserveNulls knob (default true, matching upstream). Recursions are deferred to a follow-up since they need a richer column-pair representation (RecursionUnnestOption with input/output/depth). Tests: 11 new transformation tests, 2 UnnestOptions setter tests, plus the two close/collect tests extended for the new methods. The unnest tests cover both preserveNulls=true (keep null rows) and preserveNulls=false (drop null rows). withColumn tests cover both the append-new and replace-existing branches. make test (90 tests, 0 failures) and cargo clippy/fmt are clean.
There was a problem hiding this comment.
Thanks @LantaoJin
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Which issue does this PR close?
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?
Out of scope (filed separately):
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:
No API removals, no deprecations, no behavior change for existing callers.