-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Remove dead code in UnwrapCastExprRewriter
that may mask errors
#3703
Changes from 1 commit
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 |
---|---|---|
|
@@ -122,10 +122,6 @@ impl ExprRewriter for UnwrapCastExprRewriter { | |
let right = right.as_ref().clone(); | ||
let left_type = left.get_type(&self.schema); | ||
let right_type = right.get_type(&self.schema); | ||
// can't get the data type, just return the expr | ||
if left_type.is_err() || right_type.is_err() { | ||
return Ok(expr.clone()); | ||
} | ||
// Because the plan has been done the type coercion, the left and right must be equal | ||
let left_type = left_type?; | ||
let right_type = right_type?; | ||
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 reviewed this again, and I think this is safe to remove. If we have expressions where we cannot determine the types then it indicates that an earlier rule has introduced an invalid expression. I think the change could be slightly larger, replacing lines 123 through 131 just with:
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. If we need to throw the error when can't 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. cc @alamb @andygrove 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.
Done in 139f08d |
||
|
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.
Do we know for sure that this is dead code versus untested code?
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 do not know for sure. It is clearly untested
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.
Why we need to remove this code? @alamb
From the interface
get_type
which may return error like that:Do we need to throw the error for this rule, when get an error with
get_type
of the expr?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.
My thinking was that any such error is the result of some other issue with the planning or other pass; Thus, if we ignore the error in the
UnwrapCastExprRewriter
pass we make it harder to find and debug the real underlying problem.It also has no test coverage (no test fails when this code is removed) which also makes me think all it will do is make debugging future errors harder
@liukun4515 if you think strongly this code should still be here it is fine with me and I will close the PR
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.
agree with your comments