yadavay-amzn opened a new pull request, #56941:
URL: https://github.com/apache/spark/pull/56941

   ### 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 microsecond `TimestampType` 
handling at every CBO site: `EstimationUtils.toDouble`/`fromDouble`, 
`FilterEstimation.evaluateBinary`/`evaluateInSet`, 
`UnionEstimation.isTypeSupported`, and `CatalogColumnStat` min/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 `FilterEstimationSuite` tests (range / `=` / `IN` selectivity) for the 
nanosecond types, nanosecond columns added to the Union/Join estimation tests, 
and a dedicated lossless min/max round-trip test in `StatisticsCollectionSuite` 
(a sub-microsecond value survives `toExternalString` -> `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.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to