diff --git a/crates/connect/src/dataframe.rs b/crates/connect/src/dataframe.rs index a69f655..4cb35e8 100644 --- a/crates/connect/src/dataframe.rs +++ b/crates/connect/src/dataframe.rs @@ -36,6 +36,7 @@ use spark::relation::RelType; pub use spark::write_operation::SaveMode; use arrow::array::PrimitiveArray; +use arrow::array::{Array, StringArray}; use arrow::datatypes::{DataType, Float64Type}; use arrow::json::ArrayWriter; use arrow::record_batch::RecordBatch; @@ -1038,6 +1039,15 @@ impl DataFrame { let rows = self.spark_session.client().to_arrow(plan).await?; + // ShowString returns a single-column RecordBatch with the formatted table as a string. + // Extract and print the string directly instead of wrapping it in another table. + if let Some(arr) = rows.column(0).as_any().downcast_ref::() { + if arr.len() > 0 { + println!("{}", arr.value(0)); + return Ok(()); + } + } + Ok(pretty::print_batches(&[rows])?) }