-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat(unparser): adding alias for table scan filter in sql unparser #12453
Conversation
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.
Thanks @Lordworms working on this. Overall looks good to me. Just leave some suggestions.
fn test_alias_pushdown() -> Result<()> { | ||
let schema = Schema::new(vec![ | ||
Field::new("id", DataType::Int64, false), | ||
Field::new("age", DataType::Int64, false), | ||
]); |
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.
I'm not sure if adding the unparsing test here is appropriate. 🤔 Typically, we add unparse-related tests in datafusion/sql/tests/cases/plan_to_sql.rs
I left a disabled test for this issue in the previous PR #12158. I guess we can just enable it and remove this test.
// TODO: support filters for table scan with alias. Enable this test after #12368 issue is fixed |
datafusion/sql/src/unparser/plan.rs
Outdated
.reduce(|acc, expr_result| match (acc, expr_result) { | ||
(Ok(acc_expr), Ok(expr)) => Ok(acc_expr.and(expr)), | ||
(Err(e), _) | (_, Err(e)) => Err(e), | ||
}) |
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.
We can simplify here like this
.reduce(|acc, expr_result| match (acc, expr_result) { | |
(Ok(acc_expr), Ok(expr)) => Ok(acc_expr.and(expr)), | |
(Err(e), _) | (_, Err(e)) => Err(e), | |
}) | |
.reduce(|acc, expr_result| { | |
acc.and_then(|acc_expr| { | |
expr_result.map(|expr| acc_expr.and(expr)) | |
}) | |
}) |
I think @goldmedal 's comments are all great. Once those have been addressed this PR will be ready to go from my persective. Thank you @Lordworms @goldmedal and @dmitrybugakov |
3a63ca0
to
d744393
Compare
@goldmedal @alamb @dmitrybugakov Thanks for the review! |
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.
Thanks -- looks good to me
Which issue does this PR close?
Closes #12368
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?