diff --git a/datafusion/physical-optimizer/src/window_topn.rs b/datafusion/physical-optimizer/src/window_topn.rs index e138a69652e7..40dbddfbdf9f 100644 --- a/datafusion/physical-optimizer/src/window_topn.rs +++ b/datafusion/physical-optimizer/src/window_topn.rs @@ -238,15 +238,15 @@ impl PhysicalOptimizerRule for WindowTopN { fn extract_window_limit( predicate: &Arc, ) -> Option<(usize, usize)> { - let binary = predicate.as_any().downcast_ref::()?; + let binary = predicate.downcast_ref::()?; let op = binary.op(); let left = binary.left(); let right = binary.right(); // Try Column op Literal if let (Some(col), Some(lit_val)) = ( - left.as_any().downcast_ref::(), - right.as_any().downcast_ref::(), + left.downcast_ref::(), + right.downcast_ref::(), ) { let n = scalar_to_usize(lit_val.value())?; return match *op { @@ -258,8 +258,8 @@ fn extract_window_limit( // Try Literal op Column (flipped) if let (Some(lit_val), Some(col)) = ( - left.as_any().downcast_ref::(), - right.as_any().downcast_ref::(), + left.downcast_ref::(), + right.downcast_ref::(), ) { let n = scalar_to_usize(lit_val.value())?; return match *op {