-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Combine Expr::Wildcard
and Wxpr::QualifiedWildcard
, add wildcard()
expr fn
#8105
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,19 @@ pub fn placeholder(id: impl Into<String>) -> Expr { | |
}) | ||
} | ||
|
||
/// Create an '*' [`Expr::Wildcard`] expression that matches all columns | ||
/// | ||
/// # Example | ||
/// | ||
/// ```rust | ||
/// # use datafusion_expr::{wildcard}; | ||
/// let p = wildcard(); | ||
/// assert_eq!(p.to_string(), "*") | ||
/// ``` | ||
pub fn wildcard() -> Expr { | ||
Expr::Wildcard { qualifier: None } | ||
} | ||
Comment on lines
+111
to
+113
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking that it was such a niche usecase that if anyone needed the I would be happy to add |
||
|
||
/// Return a new expression `left <op> right` | ||
pub fn binary_expr(left: Expr, op: Operator, right: Expr) -> Expr { | ||
Expr::BinaryExpr(BinaryExpr::new(Box::new(left), op, Box::new(right))) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1287,11 +1287,16 @@ pub fn project( | |
for e in expr { | ||
let e = e.into(); | ||
match e { | ||
Expr::Wildcard => { | ||
Expr::Wildcard { qualifier: None } => { | ||
projected_expr.extend(expand_wildcard(input_schema, &plan, None)?) | ||
} | ||
Expr::QualifiedWildcard { ref qualifier } => projected_expr | ||
.extend(expand_qualified_wildcard(qualifier, input_schema, None)?), | ||
Expr::Wildcard { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here is the only place where Wildcard and QualifiedWildcard are treated substantially differently |
||
qualifier: Some(qualifier), | ||
} => projected_expr.extend(expand_qualified_wildcard( | ||
&qualifier, | ||
input_schema, | ||
None, | ||
)?), | ||
_ => projected_expr | ||
.push(columnize_expr(normalize_col(e, &plan)?, input_schema)), | ||
} | ||
|
@@ -1590,7 +1595,7 @@ mod tests { | |
|
||
let plan = table_scan(Some("t1"), &employee_schema(), None)? | ||
.join_using(t2, JoinType::Inner, vec!["id"])? | ||
.project(vec![Expr::Wildcard])? | ||
.project(vec![Expr::Wildcard { qualifier: None }])? | ||
.build()?; | ||
|
||
// id column should only show up once in projection | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shows the difference in API for users (calling
wildcard()
), which I think is more consistent with other functions