-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-57735][SQL] Support nanosecond-precision timestamp types in the in-memory columnar cache #56842
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
Open
viirya
wants to merge
4
commits into
apache:master
Choose a base branch
from
viirya:nanos-timestamp-default-cache
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+253
−6
Open
[SPARK-57735][SQL] Support nanosecond-precision timestamp types in the in-memory columnar cache #56842
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b5e54e8
[SPARK-57735][SQL] Support nanosecond-precision timestamp types in th…
viirya 1528114
[SPARK-57735][SQL][FOLLOWUP] Drop dead vectorized-reader coverage in …
viirya 22a2f23
[SPARK-57735][SQL][FOLLOWUP] Collect min/max bounds for cached nanos …
viirya d856baf
[SPARK-57735][SQL][FOLLOWUP] Compute expected result before caching i…
viirya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
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.
TimestampNanosColumnStatsemitsnull/nullfor lower/upper (theCalendarInterval/IntervalColumnStatspattern), so cached nanosecond-timestamp columns get no batch-level partition pruning.The same logical type at micro precision takes a different path:
TimestampType/TimestampNTZType->LongColumnBuilder->LongColumnStats, which collects min/max. So a range filter (WHERE ts > '...') over a cachedTIMESTAMP_NTZ(6)column skips non-matching batches, while the same filter over a cachedTIMESTAMP_NTZ(9)column scans every batch.TimestampNanosValisComparable(its total order is calendar order), and ordered non-primitive cache types already keep bounds —DecimalColumnStatscollectsDecimalmin/max. So trackingupper/lowerasTimestampNanosValhere (modeled onDecimalColumnStatsrather thanIntervalColumnStats) would preserve the pruning the micro path provides.Not a correctness issue — the feature works. Is the bounds-less choice intentional (follow
CalendarInterval), or worth collecting min/max so cached nanos timestamps prune like micro timestamps?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.
Good point -- collecting min/max is the right call, thanks. You're right that the bounds-less version was a regression from the micro path:
TIMESTAMP_NTZ(6)prunes viaLongColumnStatswhileTIMESTAMP_NTZ(9)scanned every batch.Following your suggestion,
TimestampNanosColumnStatsnow collectsupper/lowerasTimestampNanosVal(modeled onDecimalColumnStatsrather thanIntervalColumnStats), using itscompareTo(which is calendar order). The pruning path is already wired for it --TimestampNTZNanosTypeis anAtomicTypesoExtractableLiteralextracts the literal, andPhysicalTimestampNTZNanosTypedefines an ordering, so the bound comparisonsbuildFiltergenerates are valid -- so cached nanos timestamps now prune like micro timestamps.Added coverage:
ColumnStatsSuiteasserts the min/max bounds for both NTZ and LTZ, andPartitionBatchPruningSuiteverifies a range filter over a cached nanos column reads fewer batches with in-memory partition pruning on than off (and returns the same rows as a pre-cache evaluation).