Skip to content

Commit 01c3b1d

Browse files
committed
DataFusion 52 migration
1 parent 8215c7e commit 01c3b1d

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

native/core/src/parquet/schema_adapter.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ use datafusion_physical_expr_adapter::{
4040
};
4141
use std::collections::HashMap;
4242
use std::sync::Arc;
43-
4443
// ============================================================================
4544
// New PhysicalExprAdapter Implementation (Recommended)
4645
// ============================================================================
@@ -119,6 +118,8 @@ impl PhysicalExprAdapter for SparkPhysicalExprAdapter {
119118
// Step 1: Handle default values for missing columns
120119
let expr = self.replace_missing_with_defaults(expr)?;
121120

121+
let expr = self.cast_datafusion_unsupported_expr(expr)?;
122+
122123
// Step 2: Delegate to default adapter for standard handling
123124
// This handles: missing columns → nulls, type mismatches → CastColumnExpr
124125
let expr = self.default_adapter.rewrite(expr)?;
@@ -160,6 +161,22 @@ impl SparkPhysicalExprAdapter {
160161
Ok(Transformed::no(expr))
161162
}
162163

164+
// Cast expressions that currently not supported in DF
165+
fn cast_datafusion_unsupported_expr(
166+
&self,
167+
expr: Arc<dyn PhysicalExpr>,
168+
) -> DataFusionResult<Arc<dyn PhysicalExpr>> {
169+
// expr.transform(|expr| {
170+
// if let Some(col) = expr.as_any().downcast_ref::<Column>() {
171+
// dbg!(col.data_type(&self.logical_file_schema));
172+
// }
173+
// Ok(Transformed::no(expr))
174+
// })
175+
// .data()
176+
177+
Ok(expr)
178+
}
179+
163180
/// Replace references to missing columns with default values.
164181
fn replace_missing_with_defaults(
165182
&self,

native/spark-expr/src/conversion_funcs/cast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,8 +2532,8 @@ impl PhysicalExpr for Cast {
25322532
self
25332533
}
25342534

2535-
fn fmt_sql(&self, _: &mut Formatter<'_>) -> std::fmt::Result {
2536-
unimplemented!()
2535+
fn fmt_sql(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2536+
Display::fmt(self, f)
25372537
}
25382538

25392539
fn data_type(&self, _: &Schema) -> DataFusionResult<DataType> {

0 commit comments

Comments
 (0)