Avoid casting REAL into DOUBLE on is_nan()#13831
Merged
findepi merged 1 commit intotrinodb:masterfrom Aug 25, 2022
Merged
Conversation
findepi
approved these changes
Aug 25, 2022
Member
Author
There was a problem hiding this comment.
I thought about it, but seems like this is how isNaN usually tested (at this class, at io.trino.type.RealOperators and at io.trino.spi.type.RealType). I can change it in all places (on a separated PR), WDYT?
Member
There was a problem hiding this comment.
Yes, we're not consistent. Sometimes we do unchecked cast ((int)) and sometimes we do a checked one (toIntExact). In new code, please use toIntExact unless there is a compelling reason not to.
b08cd57 to
1047391
Compare
findepi
reviewed
Aug 25, 2022
Member
There was a problem hiding this comment.
No need to produce TrinoException for what would be an internal bug (or a bug in a connector)
(just like some ArrayIndexOutOfBound, or NPE).
1047391 to
4e3cda7
Compare
4e3cda7 to
3b53c2c
Compare
findepi
approved these changes
Aug 25, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Improvement
Core query engine
Instead of translating
is_nan(real_column)intois_nan(cast(real_column as DOUBLE))useis_nan(real_column)directly, since REAL type can test for NaN values directly.Related issues, pull requests, and links
Documentation
( ) No documentation is needed.
(X) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
(X) No release notes entries required.
( ) Release notes entries required with the following suggested text: