[SPARK-57839][SQL] Support the nanosecond-precision timestamp types in CBO statistics estimation#56941
Open
yadavay-amzn wants to merge 1 commit into
Open
[SPARK-57839][SQL] Support the nanosecond-precision timestamp types in CBO statistics estimation#56941yadavay-amzn wants to merge 1 commit into
yadavay-amzn wants to merge 1 commit into
Conversation
…n CBO statistics estimation
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.
What changes were proposed in this pull request?
Adds cost-based optimizer (CBO) statistics estimation support for the nanosecond-precision timestamp types (
TimestampNTZNanosType,TimestampLTZNanosType), mirroring the existing microsecondTimestampTypehandling at every CBO site:EstimationUtils.toDouble/fromDouble,FilterEstimation.evaluateBinary/evaluateInSet,UnionEstimation.isTypeSupported, andCatalogColumnStatmin/max (de)serialization. Values are converted on the nanosecond scale (epochMicros * 1000 + nanosWithinMicro). Column-stat min/max are serialized with a fraction-preserving 9-digit nanosecond formatter so they round-trip losslessly.Why are the changes needed?
Filters/joins/unions over nanosecond-precision timestamp columns previously fell back to default selectivity because these types were not among the types CBO estimates. They have a natural numeric ordering, so they can be estimated the same way as microsecond timestamps.
Does this PR introduce any user-facing change?
No. Affects CBO estimation / plan costing only; query results are unchanged.
How was this patch tested?
New
FilterEstimationSuitetests (range /=/INselectivity) for the nanosecond types, nanosecond columns added to the Union/Join estimation tests, and a dedicated lossless min/max round-trip test inStatisticsCollectionSuite(a sub-microsecond value survivestoExternalString->fromExternalString). All CBO estimation suites pass.Was this patch authored or co-authored using generative AI tooling?
Authored with assistance by Claude Opus 4.8.