Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove some calls to unwrap when calling create_expr in planner.rs #269

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions core/src/execution/datafusion/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,14 +489,19 @@ impl PhysicalPlanner {
let when_then_pairs = case_when
.when
.iter()
.map(|x| self.create_expr(x, input_schema.clone()).unwrap())
.map(|x| self.create_expr(x, input_schema.clone()))
.zip(
case_when
.then
.iter()
.map(|then| self.create_expr(then, input_schema.clone()).unwrap()),
.map(|then| self.create_expr(then, input_schema.clone())),
)
.collect::<Vec<_>>();
.try_fold(Vec::new(), |mut acc, (a, b)| {
acc.push((a?, b?));
Ok::<Vec<(Arc<dyn PhysicalExpr>, Arc<dyn PhysicalExpr>)>, ExecutionError>(
acc,
)
})?;

let else_phy_expr = match &case_when.else_expr {
None => None,
Expand All @@ -516,8 +521,8 @@ impl PhysicalPlanner {
let list = expr
.lists
.iter()
.map(|x| self.create_expr(x, input_schema.clone()).unwrap())
.collect::<Vec<_>>();
.map(|x| self.create_expr(x, input_schema.clone()))
.collect::<Result<Vec<_>, _>>()?;

// if schema contains any dictionary type, we should use InListExpr instead of
// in_list as it doesn't handle value being dictionary type correctly
Expand Down Expand Up @@ -1213,14 +1218,14 @@ impl PhysicalPlanner {
let args = expr
.args
.iter()
.map(|x| self.create_expr(x, input_schema.clone()).unwrap())
.collect::<Vec<_>>();
.map(|x| self.create_expr(x, input_schema.clone()))
.collect::<Result<Vec<_>, _>>()?;

let fun_name = &expr.func;
let input_expr_types = args
.iter()
.map(|x| x.data_type(input_schema.as_ref()).unwrap())
.collect::<Vec<_>>();
.map(|x| x.data_type(input_schema.as_ref()))
.collect::<Result<Vec<_>, _>>()?;
let data_type = match expr.return_type.as_ref().map(to_arrow_datatype) {
Some(t) => t,
None => {
Expand Down
Loading