jackylee-ch opened a new pull request, #25694: URL: https://github.com/apache/datafusion/pull/25694
## Which issue does this PR close? - N/A ## Rationale for this change `count`'s statistics fast path indexes `column_statistics[col.index()]` directly. A `TableProvider` reporting fewer column statistics than its schema has columns makes `SELECT count(col)` panic with an out-of-bounds index. `sum` already guards the same access with `.get(idx)?`. ## What changes are included in this PR? Both accesses in `Count::value_from_stats` (distinct and non-distinct branches) now use `.get(col.index())?`, matching `sum.rs`, so an out-of-range column returns `None` and the optimizer falls back to computing the count. ## What is the testing strategy for this PR? Two unit tests call `value_from_stats` with a column index past the end of `column_statistics`; both panic on `main` and return `None` with this change. ## Are there any user-facing changes? `count` no longer panics when a `TableProvider` reports short column statistics. No API change. -- 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]
