@@ -207,6 +207,55 @@ public DataFrame withColumnRenamed(String oldName, String newName) {
207207 return new DataFrame (renameColumn (nativeHandle , oldName , newName ));
208208 }
209209
210+ /**
211+ * Add a column to this DataFrame computed from a SQL expression. If a column with the given name
212+ * already exists, it is replaced in place; otherwise the new column is appended. The expression
213+ * is parsed against this DataFrame's own schema, matching the convention used by {@link
214+ * #filter(String)}. The receiver remains usable and must still be closed independently.
215+ *
216+ * @throws IllegalArgumentException if {@code name} or {@code expr} is {@code null}.
217+ */
218+ public DataFrame withColumn (String name , String expr ) {
219+ if (nativeHandle == 0 ) {
220+ throw new IllegalStateException ("DataFrame is closed or already collected" );
221+ }
222+ if (name == null ) {
223+ throw new IllegalArgumentException ("withColumn name must be non-null" );
224+ }
225+ if (expr == null ) {
226+ throw new IllegalArgumentException ("withColumn expr must be non-null" );
227+ }
228+ return new DataFrame (withColumnExpr (nativeHandle , name , expr ));
229+ }
230+
231+ /**
232+ * Expand list or struct columns into rows or fields, with default {@link UnnestOptions} (i.e.
233+ * {@code preserveNulls = true}). The receiver remains usable and must still be closed
234+ * independently.
235+ */
236+ public DataFrame unnestColumns (String ... columns ) {
237+ return unnestColumns (new UnnestOptions (), columns );
238+ }
239+
240+ /**
241+ * Expand list or struct columns into rows or fields with the supplied {@link UnnestOptions}. The
242+ * receiver remains usable and must still be closed independently.
243+ *
244+ * @throws IllegalArgumentException if {@code options} or {@code columns} is {@code null}.
245+ */
246+ public DataFrame unnestColumns (UnnestOptions options , String ... columns ) {
247+ if (nativeHandle == 0 ) {
248+ throw new IllegalStateException ("DataFrame is closed or already collected" );
249+ }
250+ if (options == null ) {
251+ throw new IllegalArgumentException ("unnestColumns options must be non-null" );
252+ }
253+ if (columns == null ) {
254+ throw new IllegalArgumentException ("unnestColumns columns must be non-null" );
255+ }
256+ return new DataFrame (unnestColumns (nativeHandle , columns , options .preserveNulls ()));
257+ }
258+
210259 /**
211260 * Materialize this DataFrame as Parquet at {@code path}. The path is treated as a directory
212261 * unless overridden via {@link ParquetWriteOptions#singleFileOutput(boolean)}. The receiver
@@ -269,6 +318,10 @@ public void close() {
269318
270319 private static native long renameColumn (long handle , String oldName , String newName );
271320
321+ private static native long withColumnExpr (long handle , String name , String expr );
322+
323+ private static native long unnestColumns (long handle , String [] columns , boolean preserveNulls );
324+
272325 private static native void writeParquetWithOptions (
273326 long handle ,
274327 String path ,
0 commit comments