@@ -171,6 +171,55 @@ public DataFrame withColumnRenamed(String oldName, String newName) {
171171 return new DataFrame (renameColumn (nativeHandle , oldName , newName ));
172172 }
173173
174+ /**
175+ * Add a column to this DataFrame computed from a SQL expression. If a column with the given name
176+ * already exists, it is replaced in place; otherwise the new column is appended. The expression
177+ * is parsed against this DataFrame's own schema, matching the convention used by {@link
178+ * #filter(String)}. The receiver remains usable and must still be closed independently.
179+ *
180+ * @throws IllegalArgumentException if {@code name} or {@code expr} is {@code null}.
181+ */
182+ public DataFrame withColumn (String name , String expr ) {
183+ if (nativeHandle == 0 ) {
184+ throw new IllegalStateException ("DataFrame is closed or already collected" );
185+ }
186+ if (name == null ) {
187+ throw new IllegalArgumentException ("withColumn name must be non-null" );
188+ }
189+ if (expr == null ) {
190+ throw new IllegalArgumentException ("withColumn expr must be non-null" );
191+ }
192+ return new DataFrame (withColumnExpr (nativeHandle , name , expr ));
193+ }
194+
195+ /**
196+ * Expand list or struct columns into rows or fields, with default {@link UnnestOptions} (i.e.
197+ * {@code preserveNulls = true}). The receiver remains usable and must still be closed
198+ * independently.
199+ */
200+ public DataFrame unnestColumns (String ... columns ) {
201+ return unnestColumns (new UnnestOptions (), columns );
202+ }
203+
204+ /**
205+ * Expand list or struct columns into rows or fields with the supplied {@link UnnestOptions}. The
206+ * receiver remains usable and must still be closed independently.
207+ *
208+ * @throws IllegalArgumentException if {@code options} or {@code columns} is {@code null}.
209+ */
210+ public DataFrame unnestColumns (UnnestOptions options , String ... columns ) {
211+ if (nativeHandle == 0 ) {
212+ throw new IllegalStateException ("DataFrame is closed or already collected" );
213+ }
214+ if (options == null ) {
215+ throw new IllegalArgumentException ("unnestColumns options must be non-null" );
216+ }
217+ if (columns == null ) {
218+ throw new IllegalArgumentException ("unnestColumns columns must be non-null" );
219+ }
220+ return new DataFrame (unnestColumns (nativeHandle , columns , options .preserveNulls ()));
221+ }
222+
174223 /**
175224 * Materialize this DataFrame as Parquet at {@code path}. The path is treated as a directory
176225 * unless overridden via {@link ParquetWriteOptions#singleFileOutput(boolean)}. The receiver
@@ -263,6 +312,10 @@ public void close() {
263312
264313 private static native long renameColumn (long handle , String oldName , String newName );
265314
315+ private static native long withColumnExpr (long handle , String name , String expr );
316+
317+ private static native long unnestColumns (long handle , String [] columns , boolean preserveNulls );
318+
266319 private static native void writeParquetWithOptions (
267320 long handle ,
268321 String path ,
0 commit comments