delta-funnel 0.2.0

Lightweight, fast Delta Lake to SQL Server loads with DataFusion SQL and native TDS
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
//! Provider read progress counters for Delta scan execution.
//!
//! These counters are intentionally independent from DataFusion's metrics set.
//! They are the provider-owned handoff for later orchestration code that needs
//! partial progress after success, failure, or cancellation.

use std::sync::atomic::{AtomicU64, Ordering};

use super::scheduling::DeltaProviderReaderBackend;

/// Immutable view of provider read progress for one physical scan.
#[allow(dead_code)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DeltaProviderReadStatsSnapshot {
    /// DataFusion table name for this source.
    pub source_name: String,
    /// Delta snapshot version selected for this scan.
    pub snapshot_version: u64,
    /// Provider file-reader backend selected for this scan.
    pub reader_backend: DeltaProviderReaderBackend,
    /// Whether metadata expansion exhausted the upstream kernel scan iterator.
    pub scan_metadata_exhausted: Option<bool>,
    /// Planned DataFusion execution partitions for this scan.
    pub scan_partitions_planned: u64,
    /// Selected provider file tasks planned for this scan.
    pub files_planned: u64,
    /// Estimated output rows from planning when every selected file had stats.
    pub estimated_rows: Option<u64>,
    /// Estimated bytes from planning when every selected file had a byte size.
    pub estimated_bytes: Option<u64>,
    /// Effective DataFusion task batch size observed when execution starts.
    ///
    /// This records the upstream query-engine setting. It does not claim every
    /// produced or final query-output batch has exactly this many rows.
    pub datafusion_output_batch_size: Option<u64>,
    /// Execution partitions whose stream was started by DataFusion.
    pub scan_partitions_started: u64,
    /// Execution partitions whose stream reached normal completion.
    pub scan_partitions_completed: u64,
    /// File-read handoffs that were started.
    pub files_started: u64,
    /// File-read handoffs that finished successfully.
    pub files_completed: u64,
    /// File tasks skipped before read scheduling by dynamic partition pruning.
    pub dynamic_partition_files_pruned: u64,
    /// File tasks kept after dynamic partition pruning evaluation.
    pub dynamic_partition_files_kept: u64,
    /// Post-phase physical filters offered to the Delta dynamic filter hook.
    pub dynamic_filters_received: u64,
    /// Offered dynamic filters retained for partition pruning.
    pub dynamic_filters_accepted: u64,
    /// Offered filters rejected by the dynamic filter hook policy.
    pub dynamic_filters_unsupported: u64,
    /// Attempts to snapshot a retained dynamic filter during file admission.
    pub dynamic_filter_snapshots: u64,
    /// Kept file tasks with missing, invalid, or unparsable partition metadata.
    pub dynamic_partition_files_not_pruned_missing_metadata: u64,
    /// Kept file tasks with unsupported or failed dynamic partition evaluation.
    pub dynamic_partition_files_not_pruned_unsupported_expression: u64,
    /// Record batches sent toward DataFusion.
    pub batches_produced: u64,
    /// Rows sent toward DataFusion after transform and DV filtering.
    pub rows_produced: u64,
    /// Deletion-vector payloads loaded for selected files.
    pub deletion_vector_payloads_loaded: u64,
    /// Deletion-vector masks applied to selected files.
    pub deletion_vectors_applied: u64,
    /// Rows removed by deletion-vector masks when known.
    pub deletion_vector_rows_deleted: u64,
    /// Deletion-vector read or masking failures.
    pub deletion_vector_failures: u64,
    /// Deletion-vector reads rejected by safety gates.
    pub deletion_vector_rejections: u64,
}

/// Static context and planning estimates for one provider read stats instance.
#[allow(dead_code)]
pub(crate) struct DeltaProviderReadStatsConfig {
    /// DataFusion table name for this source.
    pub(crate) source_name: String,
    /// Delta snapshot version selected for this scan.
    pub(crate) snapshot_version: u64,
    /// Provider file-reader backend selected for this scan.
    pub(crate) reader_backend: DeltaProviderReaderBackend,
    /// Whether metadata expansion exhausted the upstream kernel scan iterator.
    pub(crate) scan_metadata_exhausted: Option<bool>,
    /// Planned DataFusion execution partitions for this scan.
    pub(crate) scan_partitions_planned: usize,
    /// Selected provider file tasks planned for this scan.
    pub(crate) files_planned: usize,
    /// Estimated output rows from planning when every selected file had stats.
    pub(crate) estimated_rows: Option<u64>,
    /// Estimated bytes from planning when every selected file had a byte size.
    pub(crate) estimated_bytes: Option<u64>,
}

/// Thread-safe provider read progress for one physical scan.
#[allow(dead_code)]
#[derive(Debug)]
pub(crate) struct DeltaProviderReadStats {
    source_name: String,
    snapshot_version: u64,
    reader_backend: DeltaProviderReaderBackend,
    scan_metadata_exhausted: Option<bool>,
    scan_partitions_planned: u64,
    files_planned: u64,
    estimated_rows: Option<u64>,
    estimated_bytes: Option<u64>,
    datafusion_output_batch_size: AtomicU64,
    scan_partitions_started: AtomicU64,
    scan_partitions_completed: AtomicU64,
    files_started: AtomicU64,
    files_completed: AtomicU64,
    dynamic_partition_files_pruned: AtomicU64,
    dynamic_partition_files_kept: AtomicU64,
    dynamic_filters_received: AtomicU64,
    dynamic_filters_accepted: AtomicU64,
    dynamic_filters_unsupported: AtomicU64,
    dynamic_filter_snapshots: AtomicU64,
    dynamic_partition_files_not_pruned_missing_metadata: AtomicU64,
    dynamic_partition_files_not_pruned_unsupported_expression: AtomicU64,
    batches_produced: AtomicU64,
    rows_produced: AtomicU64,
    deletion_vector_payloads_loaded: AtomicU64,
    deletion_vectors_applied: AtomicU64,
    deletion_vector_rows_deleted: AtomicU64,
    deletion_vector_failures: AtomicU64,
    deletion_vector_rejections: AtomicU64,
}

#[allow(dead_code)]
impl DeltaProviderReadStats {
    /// Creates zeroed read progress for one physical scan.
    #[allow(dead_code)]
    #[must_use]
    pub(crate) fn new(config: DeltaProviderReadStatsConfig) -> Self {
        Self {
            source_name: config.source_name,
            snapshot_version: config.snapshot_version,
            reader_backend: config.reader_backend,
            scan_metadata_exhausted: config.scan_metadata_exhausted,
            scan_partitions_planned: usize_to_u64_saturating(config.scan_partitions_planned),
            files_planned: usize_to_u64_saturating(config.files_planned),
            estimated_rows: config.estimated_rows,
            estimated_bytes: config.estimated_bytes,
            datafusion_output_batch_size: AtomicU64::new(0),
            scan_partitions_started: AtomicU64::new(0),
            scan_partitions_completed: AtomicU64::new(0),
            files_started: AtomicU64::new(0),
            files_completed: AtomicU64::new(0),
            dynamic_partition_files_pruned: AtomicU64::new(0),
            dynamic_partition_files_kept: AtomicU64::new(0),
            dynamic_filters_received: AtomicU64::new(0),
            dynamic_filters_accepted: AtomicU64::new(0),
            dynamic_filters_unsupported: AtomicU64::new(0),
            dynamic_filter_snapshots: AtomicU64::new(0),
            dynamic_partition_files_not_pruned_missing_metadata: AtomicU64::new(0),
            dynamic_partition_files_not_pruned_unsupported_expression: AtomicU64::new(0),
            batches_produced: AtomicU64::new(0),
            rows_produced: AtomicU64::new(0),
            deletion_vector_payloads_loaded: AtomicU64::new(0),
            deletion_vectors_applied: AtomicU64::new(0),
            deletion_vector_rows_deleted: AtomicU64::new(0),
            deletion_vector_failures: AtomicU64::new(0),
            deletion_vector_rejections: AtomicU64::new(0),
        }
    }

    /// Returns a point-in-time copy of all counters.
    #[allow(dead_code)]
    #[must_use]
    pub(crate) fn snapshot(&self) -> DeltaProviderReadStatsSnapshot {
        DeltaProviderReadStatsSnapshot {
            source_name: self.source_name.clone(),
            snapshot_version: self.snapshot_version,
            reader_backend: self.reader_backend,
            scan_metadata_exhausted: self.scan_metadata_exhausted,
            scan_partitions_planned: self.scan_partitions_planned,
            files_planned: self.files_planned,
            estimated_rows: self.estimated_rows,
            estimated_bytes: self.estimated_bytes,
            datafusion_output_batch_size: nonzero_atomic_snapshot(
                &self.datafusion_output_batch_size,
            ),
            scan_partitions_started: self.scan_partitions_started.load(Ordering::Relaxed),
            scan_partitions_completed: self.scan_partitions_completed.load(Ordering::Relaxed),
            files_started: self.files_started.load(Ordering::Relaxed),
            files_completed: self.files_completed.load(Ordering::Relaxed),
            dynamic_partition_files_pruned: self
                .dynamic_partition_files_pruned
                .load(Ordering::Relaxed),
            dynamic_partition_files_kept: self.dynamic_partition_files_kept.load(Ordering::Relaxed),
            dynamic_filters_received: self.dynamic_filters_received.load(Ordering::Relaxed),
            dynamic_filters_accepted: self.dynamic_filters_accepted.load(Ordering::Relaxed),
            dynamic_filters_unsupported: self.dynamic_filters_unsupported.load(Ordering::Relaxed),
            dynamic_filter_snapshots: self.dynamic_filter_snapshots.load(Ordering::Relaxed),
            dynamic_partition_files_not_pruned_missing_metadata: self
                .dynamic_partition_files_not_pruned_missing_metadata
                .load(Ordering::Relaxed),
            dynamic_partition_files_not_pruned_unsupported_expression: self
                .dynamic_partition_files_not_pruned_unsupported_expression
                .load(Ordering::Relaxed),
            batches_produced: self.batches_produced.load(Ordering::Relaxed),
            rows_produced: self.rows_produced.load(Ordering::Relaxed),
            deletion_vector_payloads_loaded: self
                .deletion_vector_payloads_loaded
                .load(Ordering::Relaxed),
            deletion_vectors_applied: self.deletion_vectors_applied.load(Ordering::Relaxed),
            deletion_vector_rows_deleted: self.deletion_vector_rows_deleted.load(Ordering::Relaxed),
            deletion_vector_failures: self.deletion_vector_failures.load(Ordering::Relaxed),
            deletion_vector_rejections: self.deletion_vector_rejections.load(Ordering::Relaxed),
        }
    }

    pub(crate) fn record_scan_partition_started(&self) {
        saturating_fetch_add(&self.scan_partitions_started, 1);
    }

    pub(crate) fn record_datafusion_output_batch_size(&self, batch_size: usize) {
        self.datafusion_output_batch_size
            .store(usize_to_u64_saturating(batch_size), Ordering::Relaxed);
    }

    pub(crate) fn record_scan_partition_completed(&self) {
        saturating_fetch_add(&self.scan_partitions_completed, 1);
    }

    pub(crate) fn record_file_started(&self) {
        saturating_fetch_add(&self.files_started, 1);
    }

    pub(crate) fn record_file_completed(&self) {
        saturating_fetch_add(&self.files_completed, 1);
    }

    pub(crate) fn record_dynamic_partition_file_pruned(&self) {
        saturating_fetch_add(&self.dynamic_partition_files_pruned, 1);
    }

    pub(crate) fn record_dynamic_partition_file_kept(&self) {
        saturating_fetch_add(&self.dynamic_partition_files_kept, 1);
    }

    pub(crate) fn record_dynamic_filters_received(&self, count: usize) {
        saturating_fetch_add(
            &self.dynamic_filters_received,
            usize_to_u64_saturating(count),
        );
    }

    pub(crate) fn record_dynamic_filters_accepted(&self, count: usize) {
        saturating_fetch_add(
            &self.dynamic_filters_accepted,
            usize_to_u64_saturating(count),
        );
    }

    pub(crate) fn record_dynamic_filters_unsupported(&self, count: usize) {
        saturating_fetch_add(
            &self.dynamic_filters_unsupported,
            usize_to_u64_saturating(count),
        );
    }

    pub(crate) fn record_dynamic_filter_snapshot(&self) {
        saturating_fetch_add(&self.dynamic_filter_snapshots, 1);
    }

    pub(crate) fn record_dynamic_partition_file_not_pruned_missing_metadata(&self) {
        saturating_fetch_add(&self.dynamic_partition_files_not_pruned_missing_metadata, 1);
    }

    pub(crate) fn record_dynamic_partition_file_not_pruned_unsupported_expression(&self) {
        saturating_fetch_add(
            &self.dynamic_partition_files_not_pruned_unsupported_expression,
            1,
        );
    }

    pub(crate) fn record_batch_produced(&self, rows: usize) {
        saturating_fetch_add(&self.batches_produced, 1);
        saturating_fetch_add(&self.rows_produced, usize_to_u64_saturating(rows));
    }

    pub(crate) fn record_deletion_vector_payload_loaded(&self) {
        saturating_fetch_add(&self.deletion_vector_payloads_loaded, 1);
    }

    pub(crate) fn record_deletion_vector_applied(&self, deleted_rows: usize) {
        saturating_fetch_add(&self.deletion_vectors_applied, 1);
        self.record_deletion_vector_rows_deleted(deleted_rows);
    }

    pub(crate) fn record_deletion_vector_rows_deleted(&self, deleted_rows: usize) {
        saturating_fetch_add(
            &self.deletion_vector_rows_deleted,
            usize_to_u64_saturating(deleted_rows),
        );
    }

    pub(crate) fn record_deletion_vector_failure(&self) {
        saturating_fetch_add(&self.deletion_vector_failures, 1);
    }

    pub(crate) fn record_deletion_vector_rejection(&self) {
        saturating_fetch_add(&self.deletion_vector_rejections, 1);
    }
}

#[allow(dead_code)]
fn saturating_fetch_add(counter: &AtomicU64, value: u64) {
    let mut current = counter.load(Ordering::Relaxed);
    loop {
        let next = current.saturating_add(value);
        match counter.compare_exchange_weak(current, next, Ordering::Relaxed, Ordering::Relaxed) {
            Ok(_) => return,
            Err(observed) => current = observed,
        }
    }
}

#[allow(dead_code)]
fn usize_to_u64_saturating(value: usize) -> u64 {
    u64::try_from(value).unwrap_or(u64::MAX)
}

#[allow(dead_code)]
fn nonzero_atomic_snapshot(counter: &AtomicU64) -> Option<u64> {
    match counter.load(Ordering::Relaxed) {
        0 => None,
        value => Some(value),
    }
}

#[cfg(test)]
mod tests {
    use std::sync::Arc;
    use std::thread;

    use super::{DeltaProviderReadStats, DeltaProviderReadStatsConfig};
    use crate::query_engine::datafusion::execution::DeltaProviderReaderBackend;

    #[test]
    fn read_stats_snapshot_starts_with_context_and_zero_counters() {
        let stats = DeltaProviderReadStats::new(DeltaProviderReadStatsConfig {
            source_name: "orders".to_owned(),
            snapshot_version: 7,
            reader_backend: DeltaProviderReaderBackend::OfficialKernel,
            scan_metadata_exhausted: Some(true),
            scan_partitions_planned: 3,
            files_planned: 5,
            estimated_rows: Some(99),
            estimated_bytes: Some(42),
        });
        let snapshot = stats.snapshot();

        assert_eq!(snapshot.source_name, "orders");
        assert_eq!(snapshot.snapshot_version, 7);
        assert_eq!(
            snapshot.reader_backend,
            DeltaProviderReaderBackend::OfficialKernel
        );
        assert_eq!(snapshot.scan_metadata_exhausted, Some(true));
        assert_eq!(snapshot.scan_partitions_planned, 3);
        assert_eq!(snapshot.files_planned, 5);
        assert_eq!(snapshot.estimated_rows, Some(99));
        assert_eq!(snapshot.estimated_bytes, Some(42));
        assert_eq!(snapshot.datafusion_output_batch_size, None);
        assert_eq!(snapshot.scan_partitions_started, 0);
        assert_eq!(snapshot.scan_partitions_completed, 0);
        assert_eq!(snapshot.files_started, 0);
        assert_eq!(snapshot.files_completed, 0);
        assert_eq!(snapshot.dynamic_partition_files_pruned, 0);
        assert_eq!(snapshot.dynamic_partition_files_kept, 0);
        assert_eq!(snapshot.dynamic_filters_received, 0);
        assert_eq!(snapshot.dynamic_filters_accepted, 0);
        assert_eq!(snapshot.dynamic_filters_unsupported, 0);
        assert_eq!(snapshot.dynamic_filter_snapshots, 0);
        assert_eq!(
            snapshot.dynamic_partition_files_not_pruned_missing_metadata,
            0
        );
        assert_eq!(
            snapshot.dynamic_partition_files_not_pruned_unsupported_expression,
            0
        );
        assert_eq!(snapshot.batches_produced, 0);
        assert_eq!(snapshot.rows_produced, 0);
        assert_eq!(snapshot.deletion_vector_payloads_loaded, 0);
        assert_eq!(snapshot.deletion_vectors_applied, 0);
        assert_eq!(snapshot.deletion_vector_rows_deleted, 0);
        assert_eq!(snapshot.deletion_vector_failures, 0);
        assert_eq!(snapshot.deletion_vector_rejections, 0);
    }

    #[test]
    fn read_stats_records_partial_progress_without_completing_failed_work() {
        let stats = DeltaProviderReadStats::new(DeltaProviderReadStatsConfig {
            source_name: "orders".to_owned(),
            snapshot_version: 7,
            reader_backend: DeltaProviderReaderBackend::OfficialKernel,
            scan_metadata_exhausted: Some(false),
            scan_partitions_planned: 1,
            files_planned: 1,
            estimated_rows: None,
            estimated_bytes: None,
        });

        stats.record_scan_partition_started();
        stats.record_datafusion_output_batch_size(8192);
        stats.record_file_started();
        stats.record_dynamic_partition_file_pruned();
        stats.record_dynamic_partition_file_kept();
        stats.record_dynamic_filters_received(3);
        stats.record_dynamic_filters_accepted(1);
        stats.record_dynamic_filters_unsupported(2);
        stats.record_dynamic_filter_snapshot();
        stats.record_dynamic_partition_file_not_pruned_missing_metadata();
        stats.record_dynamic_partition_file_not_pruned_unsupported_expression();
        stats.record_batch_produced(3);
        stats.record_deletion_vector_payload_loaded();
        stats.record_deletion_vector_applied(1);
        stats.record_deletion_vector_failure();

        let snapshot = stats.snapshot();

        assert_eq!(snapshot.datafusion_output_batch_size, Some(8192));
        assert_eq!(snapshot.scan_partitions_started, 1);
        assert_eq!(snapshot.scan_partitions_completed, 0);
        assert_eq!(snapshot.files_started, 1);
        assert_eq!(snapshot.files_completed, 0);
        assert_eq!(snapshot.dynamic_partition_files_pruned, 1);
        assert_eq!(snapshot.dynamic_partition_files_kept, 1);
        assert_eq!(snapshot.dynamic_filters_received, 3);
        assert_eq!(snapshot.dynamic_filters_accepted, 1);
        assert_eq!(snapshot.dynamic_filters_unsupported, 2);
        assert_eq!(snapshot.dynamic_filter_snapshots, 1);
        assert_eq!(
            snapshot.dynamic_partition_files_not_pruned_missing_metadata,
            1
        );
        assert_eq!(
            snapshot.dynamic_partition_files_not_pruned_unsupported_expression,
            1
        );
        assert_eq!(snapshot.batches_produced, 1);
        assert_eq!(snapshot.rows_produced, 3);
        assert_eq!(snapshot.deletion_vector_payloads_loaded, 1);
        assert_eq!(snapshot.deletion_vectors_applied, 1);
        assert_eq!(snapshot.deletion_vector_rows_deleted, 1);
        assert_eq!(snapshot.deletion_vector_failures, 1);
        assert_eq!(snapshot.deletion_vector_rejections, 0);
    }

    #[test]
    fn read_stats_updates_are_thread_safe() -> Result<(), Box<dyn std::error::Error>> {
        const THREADS: usize = 4;
        const ITERATIONS: usize = 100;

        let stats = Arc::new(DeltaProviderReadStats::new(DeltaProviderReadStatsConfig {
            source_name: "orders".to_owned(),
            snapshot_version: 7,
            reader_backend: DeltaProviderReaderBackend::OfficialKernel,
            scan_metadata_exhausted: None,
            scan_partitions_planned: THREADS,
            files_planned: THREADS,
            estimated_rows: None,
            estimated_bytes: None,
        }));
        let mut handles = Vec::new();

        for _ in 0..THREADS {
            let stats = Arc::clone(&stats);
            handles.push(thread::spawn(move || {
                for _ in 0..ITERATIONS {
                    stats.record_scan_partition_started();
                    stats.record_scan_partition_completed();
                    stats.record_file_started();
                    stats.record_file_completed();
                    stats.record_dynamic_partition_file_pruned();
                    stats.record_dynamic_partition_file_kept();
                    stats.record_dynamic_filters_received(3);
                    stats.record_dynamic_filters_accepted(1);
                    stats.record_dynamic_filters_unsupported(2);
                    stats.record_dynamic_filter_snapshot();
                    stats.record_dynamic_partition_file_not_pruned_missing_metadata();
                    stats.record_dynamic_partition_file_not_pruned_unsupported_expression();
                    stats.record_batch_produced(2);
                    stats.record_deletion_vector_payload_loaded();
                    stats.record_deletion_vector_applied(1);
                    stats.record_deletion_vector_rejection();
                }
            }));
        }

        for handle in handles {
            handle.join().map_err(|_| "stats worker panicked")?;
        }

        let snapshot = stats.snapshot();
        let expected = u64::try_from(THREADS * ITERATIONS)?;

        assert_eq!(snapshot.scan_metadata_exhausted, None);
        assert_eq!(snapshot.scan_partitions_started, expected);
        assert_eq!(snapshot.scan_partitions_completed, expected);
        assert_eq!(snapshot.files_started, expected);
        assert_eq!(snapshot.files_completed, expected);
        assert_eq!(snapshot.dynamic_partition_files_pruned, expected);
        assert_eq!(snapshot.dynamic_partition_files_kept, expected);
        assert_eq!(snapshot.dynamic_filters_received, expected * 3);
        assert_eq!(snapshot.dynamic_filters_accepted, expected);
        assert_eq!(snapshot.dynamic_filters_unsupported, expected * 2);
        assert_eq!(snapshot.dynamic_filter_snapshots, expected);
        assert_eq!(
            snapshot.dynamic_partition_files_not_pruned_missing_metadata,
            expected
        );
        assert_eq!(
            snapshot.dynamic_partition_files_not_pruned_unsupported_expression,
            expected
        );
        assert_eq!(snapshot.batches_produced, expected);
        assert_eq!(snapshot.rows_produced, expected * 2);
        assert_eq!(snapshot.deletion_vector_payloads_loaded, expected);
        assert_eq!(snapshot.deletion_vectors_applied, expected);
        assert_eq!(snapshot.deletion_vector_rows_deleted, expected);
        assert_eq!(snapshot.deletion_vector_rejections, expected);

        Ok(())
    }
}