Skip to content

Commit 740bb5a

Browse files
committed
maybe working from proto
1 parent 7af4953 commit 740bb5a

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

datafusion/expr/src/expr.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,11 @@ impl Placeholder {
11531153
field: data_type.map(|dt| Arc::new(Field::new("", dt, true))),
11541154
}
11551155
}
1156+
1157+
/// Create a new Placeholder expression from a Field
1158+
pub fn new_with_metadata(id: String, field: Option<FieldRef>) -> Self {
1159+
Self { id, field }
1160+
}
11561161
}
11571162

11581163
/// Grouping sets

datafusion/proto/src/logical_plan/from_proto.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
use std::sync::Arc;
1919

20+
use arrow::datatypes::Field;
2021
use datafusion::execution::registry::FunctionRegistry;
2122
use datafusion_common::{
2223
exec_datafusion_err, internal_err, plan_datafusion_err, NullEquality,
@@ -595,12 +596,23 @@ pub fn parse_expr(
595596
ExprType::Rollup(RollupNode { expr }) => Ok(Expr::GroupingSet(
596597
GroupingSet::Rollup(parse_exprs(expr, registry, codec)?),
597598
)),
598-
ExprType::Placeholder(PlaceholderNode { id, data_type }) => match data_type {
599+
ExprType::Placeholder(PlaceholderNode {
600+
id,
601+
data_type,
602+
nullable,
603+
metadata,
604+
}) => match data_type {
599605
None => Ok(Expr::Placeholder(Placeholder::new(id.clone(), None))),
600-
Some(data_type) => Ok(Expr::Placeholder(Placeholder::new(
601-
id.clone(),
602-
Some(data_type.try_into()?),
603-
))),
606+
Some(data_type) => {
607+
// Foofy
608+
let field =
609+
Field::new("", data_type.try_into()?, nullable.unwrap_or(true))
610+
.with_metadata(metadata.clone());
611+
Ok(Expr::Placeholder(Placeholder::new_with_metadata(
612+
id.clone(),
613+
Some(field.into()),
614+
)))
615+
}
604616
},
605617
}
606618
}

0 commit comments

Comments
 (0)