-
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
Return an error when a column does not exist in window function #9202
Conversation
Signed-off-by: Hoang Pham <a2k40pbc@gmail.com>
Signed-off-by: Hoang Pham <a2k40pbc@gmail.com>
Signed-off-by: Hoang Pham <a2k40pbc@gmail.com>
Signed-off-by: Hoang Pham <a2k40pbc@gmail.com>
Signed-off-by: Hoang Pham <a2k40pbc@gmail.com>
Signed-off-by: Hoang Pham <a2k40pbc@gmail.com>
Signed-off-by: Hoang Pham <a2k40pbc@gmail.com>
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.
Thank you @PhVHoang -- this is a great first contribution.
I think the code can be made simpler and I left a comment for your consideration
datafusion/sql/src/expr/function.rs
Outdated
let idx_result = schema.index_of_column(col); | ||
|
||
// Propagate the error to the caller and return it immediately | ||
let idx = idx_result |
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 think the ok()
function call here discards the error.
I think changing
let idx = schema.index_of_column(col).unwrap();
To
let idx = schema.index_of_column(col).ok()?;
accomplishes the same thing (and your test still passes)
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.
Thank you very much for your suggestion. Yes it's way simpler than that of mine.
Fixed.
Signed-off-by: Hoang Pham <a2k40pbc@gmail.com>
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.
Thank you @PhVHoang -- this looks good to me
I think it would be good if @mustafasrepo could also review this PR before we merge, if he has time
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.
lgtm thanks @PhVHoang
its better than crash
@PhVHoang please add the test also for non existent partition by column |
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 @PhVHoang for this PR. LGTM!
I think the only thing remaining before merging this PR is the suggestion from @comphead #9202 (comment) for a few more tests. I can add them hopefully later today if no one else has a chance |
Signed-off-by: Hoang Pham <a2k40pbc@gmail.com>
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.
lgtm thanks @PhVHoang
Thanks again everyone |
Which issue does this PR close?
Closes #9166.
Rationale for this change
To return an error instead of panicking when columns don't exist in window function.
What changes are included in this PR?
Code, tests
Are these changes tested?
Yes
Are there any user-facing changes?