Skip to content

Commit

Permalink
fix: when extracting metadata from expr, handle CastExpr
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedld committed Oct 15, 2024
1 parent 9aef3fc commit 8c59264
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion datafusion/physical-plan/src/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use datafusion_common::stats::Precision;
use datafusion_common::Result;
use datafusion_execution::TaskContext;
use datafusion_physical_expr::equivalence::ProjectionMapping;
use datafusion_physical_expr::expressions::Literal;
use datafusion_physical_expr::expressions::{CastExpr, Literal};

use crate::execution_plan::CardinalityEffect;
use futures::stream::{Stream, StreamExt};
Expand Down Expand Up @@ -246,6 +246,10 @@ pub(crate) fn get_field_metadata(
e: &Arc<dyn PhysicalExpr>,
input_schema: &Schema,
) -> Option<HashMap<String, String>> {
if let Some(cast) = e.as_any().downcast_ref::<CastExpr>() {
return get_field_metadata(cast.expr(), input_schema);
}

// Look up field by index in schema (not NAME as there can be more than one
// column with the same name)
e.as_any()
Expand Down

0 comments on commit 8c59264

Please sign in to comment.