fix: Integer overflow in range filter boundary conversion (#27600)#27600
Open
peterenescu wants to merge 1 commit intoprestodb:masterfrom
Open
fix: Integer overflow in range filter boundary conversion (#27600)#27600peterenescu wants to merge 1 commit intoprestodb:masterfrom
peterenescu wants to merge 1 commit intoprestodb:masterfrom
Conversation
|
|
Contributor
Reviewer's GuideAdds overflow-safe conversion from protocol Range to Velox filters for bigint, hugeint, and timestamp in the OSS Hive connector, returning AlwaysFalse/IsNull instead of overflowing when exclusive bounds sit at type limits, and updates range-combination logic to handle these new filter types correctly. Class diagram for Filter hierarchy and updated range conversion helpersclassDiagram
class Filter {
<<interface>>
+FilterKind kind()
}
class FilterKind {
<<enumeration>>
kAlwaysFalse
kIsNull
kBigintRange
kHugeintRange
kTimestampRange
}
class BigintRange {
+int64_t low
+int64_t high
+bool nullAllowed
+FilterKind kind()
}
class HugeintRange {
+int128_t low
+int128_t high
+bool nullAllowed
+FilterKind kind()
}
class TimestampRange {
+Timestamp low
+Timestamp high
+bool nullAllowed
+FilterKind kind()
}
class AlwaysFalse {
+FilterKind kind()
}
class IsNull {
+FilterKind kind()
}
class PrestoToVeloxConnectorUtils {
+bigintRangeToFilter(Range range, bool nullAllowed, VeloxExprConverter exprConverter, TypePtr type) Filter*
+hugeintRangeToFilter(Range range, bool nullAllowed, VeloxExprConverter exprConverter, TypePtr type) Filter*
+timestampRangeToFilter(Range range, bool nullAllowed, VeloxExprConverter exprConverter, TypePtr type) Filter*
+toFilter(RangeList ranges, bool nullAllowed, VeloxExprConverter exprConverter, TypePtr type) Filter*
}
Filter <|-- BigintRange
Filter <|-- HugeintRange
Filter <|-- TimestampRange
Filter <|-- AlwaysFalse
Filter <|-- IsNull
FilterKind <.. Filter
PrestoToVeloxConnectorUtils ..> Filter
PrestoToVeloxConnectorUtils ..> BigintRange
PrestoToVeloxConnectorUtils ..> HugeintRange
PrestoToVeloxConnectorUtils ..> TimestampRange
PrestoToVeloxConnectorUtils ..> AlwaysFalse
PrestoToVeloxConnectorUtils ..> IsNull
Flow diagram for overflow-safe bigintRangeToFilter conversionflowchart TD
A[Start bigintRangeToFilter] --> B[Compute lowUnbounded and highUnbounded]
B --> C[low = lowUnbounded ? int64_min : toInt64]
C --> D{!lowUnbounded and lowBound is ABOVE?}
D --> E[Check highUnbounded and compute high]:::hidden
D --> F{low == int64_max?}
classDef hidden stroke-width:0,fill-opacity:0,color:transparent
D -- No --> E
F --> G{nullAllowed?}
F -- No --> H[low++]
G --> I[Return IsNull filter]
G --> J[Return AlwaysFalse filter]
H --> E
E --> K{!highUnbounded and highBound is BELOW?}
K --> L["Return BigintRange(low, high, nullAllowed)"]
K --> M{high == int64_min?}
M --> N{nullAllowed?}
M -- No --> O[high--]
N --> P[Return IsNull filter]
N --> Q[Return AlwaysFalse filter]
O --> L
style A stroke:#333,stroke-width:1px
style L stroke:#333,stroke-width:1px
style I stroke:#333,stroke-width:1px
style J stroke:#333,stroke-width:1px
style P stroke:#333,stroke-width:1px
style Q stroke:#333,stroke-width:1px
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Now that bigintRangeToFilter/hugeintRangeToFilter/timestampRangeToFilter return common::Filter, make sure all their call sites are updated to handle possible AlwaysFalse/IsNull results consistently, not just the bigint ranges case in toFilter.
- The overflow handling for bigint, hugeint, and timestamp ranges is duplicated; consider extracting a small helper (e.g., a template or lambda taking min/max and nullAllowed) to centralize the guard and avoid future divergence between these three paths.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Now that bigintRangeToFilter/hugeintRangeToFilter/timestampRangeToFilter return common::Filter, make sure all their call sites are updated to handle possible AlwaysFalse/IsNull results consistently, not just the bigint ranges case in toFilter.
- The overflow handling for bigint, hugeint, and timestamp ranges is duplicated; consider extracting a small helper (e.g., a template or lambda taking min/max and nullAllowed) to centralize the guard and avoid future divergence between these three paths.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
|
d65086c to
9e00ede
Compare
peterenescu
added a commit
to peterenescu/presto
that referenced
this pull request
Apr 16, 2026
…7600) Summary: Guard against integer overflow when converting exclusive bounds to inclusive bounds for BigintRange, HugeintRange, and TimestampRange filters in the OSS Hive connector. When the boundary value is at the type limit, return AlwaysFalse or IsNull instead of overflowing. This mirrors the fix applied to the Prism connector and Velox expression filters. Differential Revision: D101072577
9e00ede to
67b4637
Compare
67b4637 to
1778e7e
Compare
peterenescu
added a commit
to peterenescu/presto
that referenced
this pull request
Apr 16, 2026
…7600) Summary: Guard against integer overflow when converting exclusive bounds to inclusive bounds for BigintRange, HugeintRange, and TimestampRange filters in the OSS Hive connector. When the boundary value is at the type limit, return AlwaysFalse or IsNull instead of overflowing. This mirrors the fix applied to the Prism connector and Velox expression filters. ``` NO RELEASE NOTE ``` Differential Revision: D101072577
1778e7e to
91b6532
Compare
peterenescu
added a commit
to peterenescu/presto
that referenced
this pull request
Apr 16, 2026
…7600) Summary: Guard against integer overflow when converting exclusive bounds to inclusive bounds for BigintRange, HugeintRange, and TimestampRange filters in the OSS Hive connector. When the boundary value is at the type limit, return AlwaysFalse or IsNull instead of overflowing. This mirrors the fix applied to the Prism connector and Velox expression filters. ``` NO RELEASE NOTE ``` Differential Revision: D101072577
91b6532 to
547c44b
Compare
…7600) Summary: Pull Request resolved: prestodb#27600 Guard against integer overflow when converting exclusive bounds to inclusive bounds for BigintRange, HugeintRange, and TimestampRange filters in the OSS Hive connector. When the boundary value is at the type limit, return AlwaysFalse or IsNull instead of overflowing. This mirrors the fix applied to the Prism connector and Velox expression filters. ``` NO RELEASE NOTE ``` Differential Revision: D101072577
547c44b to
66d2dab
Compare
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.
Summary:
Guard against integer overflow when converting exclusive bounds to inclusive bounds for BigintRange, HugeintRange, and TimestampRange filters in the OSS Hive connector. When the boundary value is at the type limit, return AlwaysFalse or IsNull instead of overflowing. This mirrors the fix applied to the Prism connector and Velox expression filters.
Differential Revision: D101072577