Skip to content
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
29 changes: 16 additions & 13 deletions datafusion/src/sql/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1341,22 +1341,25 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
}

SQLExpr::CompoundIdentifier(ids) => {
let mut var_names = vec![];
for id in ids {
var_names.push(id.value.clone());
}
let mut var_names: Vec<_> =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more rust flavor 😄

ids.iter().map(|id| id.value.clone()).collect();

if &var_names[0][0..1] == "@" {
Ok(Expr::ScalarVariable(var_names))
} else if var_names.len() == 2 {
// table.column identifier
let name = var_names.pop().unwrap();
let relation = Some(var_names.pop().unwrap());
Ok(Expr::Column(Column { relation, name }))
} else {
Err(DataFusionError::NotImplemented(format!(
"Unsupported compound identifier '{:?}'",
var_names,
)))
match (var_names.pop(), var_names.pop()) {
(Some(name), Some(relation)) if var_names.is_empty() => {
// table.column identifier
Ok(Expr::Column(Column {
relation: Some(relation),
name,
}))
}
_ => Err(DataFusionError::NotImplemented(format!(
"Unsupported compound identifier '{:?}'",
var_names,
))),
}
}
}

Expand Down