Add error handling for saturated floor cast#17014
Merged
sopel39 merged 1 commit intotrinodb:masterfrom May 24, 2023
Merged
Conversation
findepi
approved these changes
Apr 13, 2023
core/trino-main/src/test/java/io/trino/sql/planner/TestDomainTranslator.java
Outdated
Show resolved
Hide resolved
a28b43d to
3073c7a
Compare
findepi
reviewed
May 3, 2023
core/trino-main/src/main/java/io/trino/sql/planner/DomainTranslator.java
Outdated
Show resolved
Hide resolved
An exception wasn't thrown until today because of rule ordering. For example, double NaN can't be cast to smallint. Given the query "SELECT * FROM (VALUES SMALLINT '1') t(a) WHERE a IS DISTINCT FROM nan()", the filter's predicate is replaced with TRUE by UnwrapCastInComparison.FilterExpressionRewrite before hitting DomainTranslator. When manually disabling this rule, a TrinoException with the message "Unable to cast double NaN to smallint" is thrown by DoubleOperators#saturatedFloorCastToLong.
dab8061 to
250dcb5
Compare
findepi
approved these changes
May 10, 2023
Member
sopel39
approved these changes
May 22, 2023
| .map(floorValue -> rewriteComparisonExpression(symbolExpressionType, symbolExpression, valueType, value, floorValue, comparisonOperator)); | ||
| Optional<Object> floorValueOptional; | ||
| try { | ||
| floorValueOptional = floorValue(valueType, symbolExpressionType, value); |
Member
There was a problem hiding this comment.
Is this the only usage of SaturatedFloorCast that needs to be fixed?
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
An exception wasn't thrown until today because of rule ordering. For example,
double NaNcan't be cast tosmallint. Given the querySELECT * FROM (VALUES SMALLINT '1') t(a) WHERE a IS DISTINCT FROM nan(), the filter's predicate is replaced withTRUEbyUnwrapCastInComparison.FilterExpressionRewritebefore hittingDomainTranslator. When manually disabling this rule, aTrinoExceptionwith the messageUnable to cast double NaN to smallintis thrown byDoubleOperators#saturatedFloorCastToLong.Additional context and related issues
Blocking #16206
Release notes
( X ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text: