Commit 8a91db5
Move statistics handling into FileScanConfig (#18721)
## Summary
This PR moves statistics handling from individual `FileSource`
implementations into `FileScanConfig`, simplifying the `FileSource`
trait interface.
The `FileSource`s were all acting as a container for the statistics but
never actually using them.
Since `FileScanConfig` deals with file-level things (which the
statistics are) it is better equipped to deal with it.
### Changes
- **FileSource trait simplification**: Removed `statistics()`,
`with_statistics()`, and `with_projection()` methods
- **FileScanConfig enhancement**: Added `statistics` field and
`statistics()` method
- **FileSource implementations updated**: Removed `projected_statistics`
field from all implementations:
- ParquetSource
- CsvSource
- JsonSource
- AvroSource
- ArrowFileSource and ArrowStreamFileSource
- MockSource (test utility)
- **Test utilities**: Updated assertions to use `config.statistics()`
instead of `file_source.statistics()`
- **Proto serialization**: Updated to use `config.statistics()`
### Benefits
1. **Simpler trait interface**: `FileSource` implementations no longer
need to manage statistics
2. **Centralized statistics**: All statistics are now managed
consistently in `FileScanConfig`
3. **Cleaner API**: Statistics lifecycle is clearer and less error-prone
4. **Reduced code duplication**: Removes ~140 lines of boilerplate
across implementations
### Related
This is part of the projection refactoring work in #18627. This PR
extracts just the statistics-related changes to make review easier. The
full projection refactoring will come in subsequent PRs.
## Test plan
- [x] All modified file source implementations compile
- [x] Test utilities updated and compile
- [x] CI tests pass (will verify after PR creation)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Martin Grigorov <[email protected]>1 parent 7d8b860 commit 8a91db5
File tree
13 files changed
+126
-171
lines changed- datafusion
- core/tests/physical_optimizer
- filter_pushdown
- datasource-arrow/src
- datasource-avro/src
- datasource-csv/src
- datasource-json/src
- datasource-parquet/src
- datasource/src
- proto
- src/physical_plan
- tests/cases
- docs/source/library-user-guide
13 files changed
+126
-171
lines changedLines changed: 1 addition & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
112 | 111 | | |
113 | 112 | | |
114 | 113 | | |
| |||
128 | 127 | | |
129 | 128 | | |
130 | 129 | | |
131 | | - | |
132 | 130 | | |
133 | 131 | | |
134 | 132 | | |
| |||
175 | 173 | | |
176 | 174 | | |
177 | 175 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | 176 | | |
186 | 177 | | |
187 | 178 | | |
188 | 179 | | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | 180 | | |
198 | 181 | | |
199 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
| 134 | + | |
138 | 135 | | |
139 | 136 | | |
140 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
254 | 253 | | |
255 | 254 | | |
256 | 255 | | |
| |||
261 | 260 | | |
262 | 261 | | |
263 | 262 | | |
264 | | - | |
265 | 263 | | |
266 | 264 | | |
267 | 265 | | |
| |||
272 | 270 | | |
273 | 271 | | |
274 | 272 | | |
275 | | - | |
276 | 273 | | |
277 | 274 | | |
278 | 275 | | |
| |||
305 | 302 | | |
306 | 303 | | |
307 | 304 | | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | 305 | | |
315 | 306 | | |
316 | 307 | | |
| |||
319 | 310 | | |
320 | 311 | | |
321 | 312 | | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | 313 | | |
330 | 314 | | |
331 | 315 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| |||
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
44 | | - | |
45 | 43 | | |
46 | 44 | | |
47 | 45 | | |
| |||
53 | 51 | | |
54 | 52 | | |
55 | 53 | | |
56 | | - | |
57 | 54 | | |
58 | 55 | | |
59 | 56 | | |
| |||
95 | 92 | | |
96 | 93 | | |
97 | 94 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | 95 | | |
105 | 96 | | |
106 | 97 | | |
| |||
111 | 102 | | |
112 | 103 | | |
113 | 104 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | 105 | | |
122 | 106 | | |
123 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | 93 | | |
95 | 94 | | |
96 | 95 | | |
| |||
103 | 102 | | |
104 | 103 | | |
105 | 104 | | |
106 | | - | |
107 | 105 | | |
108 | 106 | | |
109 | 107 | | |
| |||
266 | 264 | | |
267 | 265 | | |
268 | 266 | | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | 267 | | |
276 | 268 | | |
277 | 269 | | |
| |||
281 | 273 | | |
282 | 274 | | |
283 | 275 | | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
| 276 | + | |
290 | 277 | | |
291 | 278 | | |
292 | 279 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
| |||
79 | 78 | | |
80 | 79 | | |
81 | 80 | | |
82 | | - | |
83 | 81 | | |
84 | 82 | | |
85 | 83 | | |
| |||
90 | 88 | | |
91 | 89 | | |
92 | 90 | | |
93 | | - | |
94 | 91 | | |
95 | 92 | | |
96 | 93 | | |
| |||
133 | 130 | | |
134 | 131 | | |
135 | 132 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | 133 | | |
143 | 134 | | |
144 | 135 | | |
| |||
147 | 138 | | |
148 | 139 | | |
149 | 140 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | 141 | | |
158 | 142 | | |
159 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | | - | |
290 | 289 | | |
291 | 290 | | |
292 | 291 | | |
| |||
307 | 306 | | |
308 | 307 | | |
309 | 308 | | |
310 | | - | |
311 | 309 | | |
312 | 310 | | |
313 | 311 | | |
| |||
625 | 623 | | |
626 | 624 | | |
627 | 625 | | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | 626 | | |
635 | 627 | | |
636 | 628 | | |
| |||
639 | 631 | | |
640 | 632 | | |
641 | 633 | | |
642 | | - | |
643 | | - | |
644 | | - | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | 634 | | |
660 | 635 | | |
661 | 636 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
72 | | - | |
73 | 71 | | |
74 | 72 | | |
75 | 73 | | |
76 | 74 | | |
77 | 75 | | |
78 | 76 | | |
79 | | - | |
80 | | - | |
81 | 77 | | |
82 | 78 | | |
83 | 79 | | |
| |||
0 commit comments