Commit 028e351
Add files_processed and files_scanned metrics to FileStreamMetrics (#20592)
## Summary
- Add `files_processed` counter to `FileStreamMetrics`, incremented for
every file assigned to the partition — whether it was opened, pruned
(returned an empty stream), or skipped due to a LIMIT. When the stream
completes, this equals the total number of files in the partition.
- Add `files_opened` counter to `FileStreamMetrics`, incremented as soon
as we consider a file for processing (either actually opened, discarded
because of a LIMIT or stats, etc.).
## Motivation
These metrics enable **tracking query progress** during long-running
scans. Today, there is no way to monitor how far along a file scan is.
The existing `FileStreamMetrics` only provide:
- **Timing metrics** (`time_elapsed_opening`,
`time_elapsed_scanning_total`, etc.) — these measure duration but don't
indicate progress. You can't tell whether a scan is 10% or 90% done from
elapsed time alone.
- **Error counters** (`file_open_errors`, `file_scan_errors`) — these
only count failures, not successful progress.
- **`output_rows`** or **`bytes_scanned`** (from `BaselineMetrics`) —
counts rows emitted, but since we don't know upfront how many rows will
be emitted in total this is a poor metric, i.e. it never converges to
100% if there are filters, etc.
In contrast, `files_processed` and `files_opened` combined with the
known number of files in `file_groups` give a clear progress indicator:
`files_processed / total_files`. This is the most natural and reliable
way to track scan progress since the file count is known at plan time.
Depending on what users plan to do with the metric they can pick
`files_opened / total_files` (leading metric) or `files_processed /
total_files` (lagging metric).
## Test plan
- [x] Existing `file_stream` tests pass (8/8)
- [x] `cargo check -p datafusion-datasource` compiles cleanly
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 909608a commit 028e351
1 file changed
Lines changed: 54 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| |||
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| 154 | + | |
153 | 155 | | |
154 | 156 | | |
155 | 157 | | |
| |||
179 | 181 | | |
180 | 182 | | |
181 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
182 | 193 | | |
183 | 194 | | |
184 | 195 | | |
| |||
196 | 207 | | |
197 | 208 | | |
198 | 209 | | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
213 | 227 | | |
214 | 228 | | |
215 | 229 | | |
| 230 | + | |
216 | 231 | | |
217 | | - | |
218 | | - | |
| 232 | + | |
219 | 233 | | |
220 | 234 | | |
221 | 235 | | |
222 | 236 | | |
223 | 237 | | |
224 | 238 | | |
225 | 239 | | |
| 240 | + | |
226 | 241 | | |
227 | 242 | | |
228 | 243 | | |
| |||
399 | 414 | | |
400 | 415 | | |
401 | 416 | | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
402 | 433 | | |
403 | 434 | | |
404 | 435 | | |
| |||
433 | 464 | | |
434 | 465 | | |
435 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
436 | 472 | | |
437 | 473 | | |
438 | 474 | | |
439 | 475 | | |
440 | 476 | | |
441 | 477 | | |
442 | 478 | | |
| 479 | + | |
| 480 | + | |
443 | 481 | | |
444 | 482 | | |
445 | 483 | | |
| |||
0 commit comments