Skip to content

Commit ab809d1

Browse files
committed
Fix after merging in latest datafusion main in the feature branch.
1 parent 276ad63 commit ab809d1

6 files changed

Lines changed: 16 additions & 45 deletions

File tree

native/core/src/execution/expressions/arithmetic.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ impl Hash for CheckedBinaryExpr {
7777
}
7878

7979
impl PhysicalExpr for CheckedBinaryExpr {
80-
fn as_any(&self) -> &dyn Any {
81-
self
82-
}
83-
8480
fn fmt_sql(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
8581
self.child.fmt_sql(f)
8682
}

native/core/src/execution/expressions/strings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl ExpressionBuilder for RlikeBuilder {
9191
let left = planner.create_expr(expr.left.as_ref().unwrap(), Arc::clone(&input_schema))?;
9292
let right = planner.create_expr(expr.right.as_ref().unwrap(), input_schema)?;
9393

94-
match right.as_any().downcast_ref::<Literal>().unwrap().value() {
94+
match right.downcast_ref::<Literal>().unwrap().value() {
9595
ScalarValue::Utf8(Some(pattern)) => Ok(Arc::new(RLike::try_new(left, pattern)?)),
9696
_ => Err(ExecutionError::GeneralError(
9797
"RLike only supports scalar patterns".to_string(),

native/core/src/execution/expressions/subquery.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use jni::{
2929
sys::{jboolean, jbyte, jint, jlong, jshort},
3030
};
3131
use std::{
32-
any::Any,
3332
fmt::{Display, Formatter},
3433
hash::Hash,
3534
sync::Arc,
@@ -63,10 +62,6 @@ impl Display for Subquery {
6362
}
6463

6564
impl PhysicalExpr for Subquery {
66-
fn as_any(&self) -> &dyn Any {
67-
self
68-
}
69-
7065
fn fmt_sql(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
7166
Display::fmt(self, f)
7267
}

native/core/src/execution/planner.rs

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ impl PhysicalPlanner {
233233
let literal =
234234
self.create_expr(partition_value, Arc::<Schema>::clone(&empty_schema))?;
235235
literal
236-
.as_any()
237236
.downcast_ref::<DataFusionLiteral>()
238237
.ok_or_else(|| {
239238
GeneralError("Expected literal of partition value".to_string())
@@ -424,11 +423,7 @@ impl PhysicalPlanner {
424423

425424
// WideDecimalBinaryExpr already handles overflow — skip redundant check
426425
// but only if its output type matches CheckOverflow's declared type
427-
if child
428-
.as_any()
429-
.downcast_ref::<WideDecimalBinaryExpr>()
430-
.is_some()
431-
{
426+
if child.downcast_ref::<WideDecimalBinaryExpr>().is_some() {
432427
let child_type = child.data_type(&input_schema)?;
433428
if child_type == data_type {
434429
return Ok(child);
@@ -437,7 +432,7 @@ impl PhysicalPlanner {
437432

438433
// Fuse Cast(Decimal128→Decimal128) + CheckOverflow into single rescale+check
439434
// Only fuse when the Cast target type matches the CheckOverflow output type
440-
if let Some(cast) = child.as_any().downcast_ref::<Cast>() {
435+
if let Some(cast) = child.downcast_ref::<Cast>() {
441436
if let (
442437
DataType::Decimal128(p_out, s_out),
443438
Ok(DataType::Decimal128(_p_in, s_in)),
@@ -1166,12 +1161,10 @@ impl PhysicalPlanner {
11661161
.iter()
11671162
.map(|expr| {
11681163
let literal = self.create_expr(expr, Arc::clone(&required_schema))?;
1169-
let df_literal = literal
1170-
.as_any()
1171-
.downcast_ref::<DataFusionLiteral>()
1172-
.ok_or_else(|| {
1173-
GeneralError("Expected literal of default value.".to_string())
1174-
})?;
1164+
let df_literal =
1165+
literal.downcast_ref::<DataFusionLiteral>().ok_or_else(|| {
1166+
GeneralError("Expected literal of default value.".to_string())
1167+
})?;
11751168
Ok(df_literal.value().clone())
11761169
})
11771170
.collect();
@@ -2552,8 +2545,7 @@ impl PhysicalPlanner {
25522545
&boundary_row.partition_bounds[col_idx],
25532546
Arc::clone(&input_schema),
25542547
)?;
2555-
let literal_expr =
2556-
expr.as_any().downcast_ref::<Literal>().expect("Literal");
2548+
let literal_expr = expr.downcast_ref::<Literal>().expect("Literal");
25572549
col_values.push(literal_expr.value().clone());
25582550
}
25592551
}
@@ -2663,12 +2655,7 @@ impl PhysicalPlanner {
26632655
// TODO this should try and find scalar
26642656
let arguments = args
26652657
.iter()
2666-
.map(|e| {
2667-
e.as_ref()
2668-
.as_any()
2669-
.downcast_ref::<Literal>()
2670-
.map(|lit| lit.value())
2671-
})
2658+
.map(|e| e.as_ref().downcast_ref::<Literal>().map(|lit| lit.value()))
26722659
.collect::<Vec<_>>();
26732660

26742661
let args = ReturnFieldArgs {
@@ -2772,7 +2759,7 @@ fn expr_to_columns(
27722759

27732760
expr.apply(&mut |expr: &Arc<dyn PhysicalExpr>| {
27742761
Ok({
2775-
if let Some(column) = expr.as_any().downcast_ref::<Column>() {
2762+
if let Some(column) = expr.downcast_ref::<Column>() {
27762763
if column.index() > left_field_len + right_field_len {
27772764
return Err(DataFusionError::Internal(format!(
27782765
"Column index {} out of range",
@@ -2823,7 +2810,7 @@ impl TreeNodeRewriter for JoinFilterRewriter<'_> {
28232810
type Node = Arc<dyn PhysicalExpr>;
28242811

28252812
fn f_down(&mut self, node: Self::Node) -> datafusion::common::Result<Transformed<Self::Node>> {
2826-
if let Some(column) = node.as_any().downcast_ref::<Column>() {
2813+
if let Some(column) = node.downcast_ref::<Column>() {
28272814
if column.index() < self.left_field_len {
28282815
// left side
28292816
let new_index = self

native/core/src/parquet/cast_column.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use datafusion::common::ScalarValue;
3131
use datafusion::logical_expr::ColumnarValue;
3232
use datafusion::physical_expr::PhysicalExpr;
3333
use std::{
34-
any::Any,
3534
fmt::{self, Display},
3635
hash::Hash,
3736
sync::Arc,
@@ -250,10 +249,6 @@ impl Display for CometCastColumnExpr {
250249
}
251250

252251
impl PhysicalExpr for CometCastColumnExpr {
253-
fn as_any(&self) -> &dyn Any {
254-
self
255-
}
256-
257252
fn data_type(&self, _input_schema: &Schema) -> DataFusionResult<DataType> {
258253
Ok(self.target_field.data_type().clone())
259254
}

native/core/src/parquet/schema_adapter.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl PhysicalExprAdapter for SparkPhysicalExprAdapter {
216216
// Walk the expression tree to find Column references
217217
let mut duplicate_err: Option<DataFusionError> = None;
218218
let _ = Arc::<dyn PhysicalExpr>::clone(&expr).transform(|e| {
219-
if let Some(col) = e.as_any().downcast_ref::<Column>() {
219+
if let Some(col) = e.downcast_ref::<Column>() {
220220
if let Some((req, matched)) = check_column_duplicate(col.name(), orig_physical)
221221
{
222222
duplicate_err = Some(DataFusionError::External(Box::new(
@@ -266,7 +266,7 @@ impl PhysicalExprAdapter for SparkPhysicalExprAdapter {
266266
// the actual parquet stream schema, which uses the original physical names.
267267
let expr = if let Some(name_map) = &self.logical_to_physical_names {
268268
expr.transform(|e| {
269-
if let Some(col) = e.as_any().downcast_ref::<Column>() {
269+
if let Some(col) = e.downcast_ref::<Column>() {
270270
if let Some(physical_name) = name_map.get(col.name()) {
271271
return Ok(Transformed::yes(Arc::new(Column::new(
272272
physical_name,
@@ -295,7 +295,7 @@ impl SparkPhysicalExprAdapter {
295295
expr: Arc<dyn PhysicalExpr>,
296296
) -> DataFusionResult<Arc<dyn PhysicalExpr>> {
297297
expr.transform(|e| {
298-
if let Some(column) = e.as_any().downcast_ref::<Column>() {
298+
if let Some(column) = e.downcast_ref::<Column>() {
299299
let col_name = column.name();
300300

301301
// Resolve fields by name because this is the fallback path
@@ -376,15 +376,13 @@ impl SparkPhysicalExprAdapter {
376376
expr: Arc<dyn PhysicalExpr>,
377377
) -> DataFusionResult<Transformed<Arc<dyn PhysicalExpr>>> {
378378
// Check for CastExpr and replace with spark_expr::Cast
379-
if let Some(cast) = expr
380-
.as_any()
381-
.downcast_ref::<datafusion::physical_expr::expressions::CastExpr>()
379+
if let Some(cast) = expr.downcast_ref::<datafusion::physical_expr::expressions::CastExpr>()
382380
{
383381
let child = Arc::clone(cast.expr());
384382
let target_type = cast.target_field().data_type();
385383

386384
// Derive input field from the child Column expression and the physical schema
387-
let input_field = if let Some(col) = child.as_any().downcast_ref::<Column>() {
385+
let input_field = if let Some(col) = child.downcast_ref::<Column>() {
388386
Arc::new(self.physical_file_schema.field(col.index()).clone())
389387
} else {
390388
// Fallback: synthesize a field from the target field name and child data type

0 commit comments

Comments
 (0)