algeon-query-runtime 0.1.2

Native query runtime, lifecycle, ledger, and observation owners.
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
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
use serde_json::{Value, json};

use super::QueryMetrics;

/// Physical unit or logical value class for a diagnostic metric.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum MetricUnit {
    /// Unitless count.
    Count,
    /// Row count.
    Rows,
    /// Bytes resident on or allocated from device memory.
    DeviceBytes,
    /// Bytes resident in host memory.
    HostBytes,
    /// Parquet compressed bytes.
    ParquetBytes,
    /// Time in nanoseconds.
    Nanos,
    /// Time in milliseconds.
    Millis,
    /// Boolean flag.
    Boolean,
    /// Stable string label.
    Label,
}

impl MetricUnit {
    /// Stable descriptor label.
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::Count => "count",
            Self::Rows => "rows",
            Self::DeviceBytes => "device_bytes",
            Self::HostBytes => "host_bytes",
            Self::ParquetBytes => "parquet_bytes",
            Self::Nanos => "nanos",
            Self::Millis => "millis",
            Self::Boolean => "boolean",
            Self::Label => "label",
        }
    }
}

/// How values for a metric are aggregated over a query.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum MetricAggregation {
    /// Values are summed over the query lifetime.
    Sum,
    /// Value is the maximum observed point-in-time value.
    Peak,
    /// Value is the final query-level label or mode.
    Last,
    /// Value is the number of nested evidence rows.
    RowCount,
}

impl MetricAggregation {
    /// Stable descriptor label.
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::Sum => "sum",
            Self::Peak => "peak",
            Self::Last => "last",
            Self::RowCount => "row_count",
        }
    }
}

/// Directional health hint for metrics that have an obvious desired movement.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum MetricDirection {
    /// Lower values are usually healthier.
    LowerIsBetter,
    /// Higher values are usually healthier.
    HigherIsBetter,
    /// No universal health direction.
    Informational,
}

impl MetricDirection {
    /// Stable descriptor label.
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::LowerIsBetter => "lower_is_better",
            Self::HigherIsBetter => "higher_is_better",
            Self::Informational => "informational",
        }
    }
}

/// Machine-readable descriptor for one query metric or exported evidence row set.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct MetricDescriptor {
    /// Stable metric name.
    pub name: &'static str,
    /// Metric unit.
    pub unit: MetricUnit,
    /// Query-level aggregation semantics.
    pub aggregation: MetricAggregation,
    /// One-line human-readable semantics.
    pub semantics: &'static str,
    /// Optional direction of healthier values. `None` supplies no directional hint.
    pub direction: Option<MetricDirection>,
    /// Optional healthy-value hint. `None` supplies no recommended value or range.
    pub healthy: Option<&'static str>,
}

impl MetricDescriptor {
    /// Serializes the descriptor as a named JSON object.
    pub fn to_json(self) -> Value {
        json!({
            "name": self.name,
            "unit": self.unit.as_str(),
            "aggregation": self.aggregation.as_str(),
            "semantics": self.semantics,
            "direction": self.direction.map(MetricDirection::as_str),
            "healthy": self.healthy,
        })
    }
}

const fn metric(
    name: &'static str,
    unit: MetricUnit,
    aggregation: MetricAggregation,
    semantics: &'static str,
    direction: Option<MetricDirection>,
    healthy: Option<&'static str>,
) -> MetricDescriptor {
    MetricDescriptor { name, unit, aggregation, semantics, direction, healthy }
}

/// QueryMetrics scalar and nested-row descriptors.
pub(crate) const QUERY_METRIC_DESCRIPTORS: &[MetricDescriptor] = &[
    metric(
        "input_batches",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Input Arrow batches observed by native execution.",
        None,
        None,
    ),
    metric(
        "input_rows",
        MetricUnit::Rows,
        MetricAggregation::Sum,
        "Input rows observed by native execution.",
        None,
        None,
    ),
    metric(
        "gpu_resident_input_handoffs",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "GPU-resident child outputs handed directly to native execution.",
        Some(MetricDirection::HigherIsBetter),
        None,
    ),
    metric(
        "host_to_device_uploads",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Host-to-device upload operations.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "host_to_device_uploaded_rows",
        MetricUnit::Rows,
        MetricAggregation::Sum,
        "Rows uploaded from host to device.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "host_to_device_uploaded_bytes",
        MetricUnit::HostBytes,
        MetricAggregation::Sum,
        "Bytes uploaded from host to device.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "device_to_host_materializations",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Device-to-host materialization operations.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "device_to_host_materialized_rows",
        MetricUnit::Rows,
        MetricAggregation::Sum,
        "Rows materialized from device to host.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "device_to_host_materialized_bytes",
        MetricUnit::DeviceBytes,
        MetricAggregation::Sum,
        "Bytes materialized from device to host.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "device_to_device_copies",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Device-to-device copy operations.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "device_to_device_copied_bytes",
        MetricUnit::DeviceBytes,
        MetricAggregation::Sum,
        "Bytes copied between device frames.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "max_task_observed_peak_bytes",
        MetricUnit::DeviceBytes,
        MetricAggregation::Peak,
        "Largest lower-level cuDF peak bytes reported by a task-like operation.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "max_task_observed_peak_bytes_observed",
        MetricUnit::Boolean,
        MetricAggregation::Last,
        "Whether max_task_observed_peak_bytes was reported by a lower layer.",
        None,
        None,
    ),
    metric(
        "max_task_retained_bytes",
        MetricUnit::DeviceBytes,
        MetricAggregation::Peak,
        "Largest retained byte count reported by a task-like lower-level cuDF operation.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "max_task_retained_bytes_observed",
        MetricUnit::Boolean,
        MetricAggregation::Last,
        "Whether max_task_retained_bytes was reported by a lower layer.",
        None,
        None,
    ),
    metric(
        "native_graph_claim_calibration_rows",
        MetricUnit::Count,
        MetricAggregation::RowCount,
        "Nested measured graph-execution peak rows.",
        None,
        None,
    ),
    metric(
        "native_graph_runtime_rows",
        MetricUnit::Count,
        MetricAggregation::RowCount,
        "Nested graph algorithm runtime evidence rows.",
        None,
        None,
    ),
    metric(
        "native_task_operator_rows",
        MetricUnit::Count,
        MetricAggregation::RowCount,
        "Nested per-operator task aggregate rows.",
        None,
        None,
    ),
    metric(
        "native_task_runtime_rows",
        MetricUnit::Count,
        MetricAggregation::RowCount,
        "Nested per-compiled-task runtime rows.",
        None,
        None,
    ),
    metric(
        "native_plan_task_mapping_rows",
        MetricUnit::Count,
        MetricAggregation::RowCount,
        "Nested native plan-node to compiled-task mapping rows.",
        None,
        None,
    ),
    metric(
        "native_dynamic_filter_runtime_rows",
        MetricUnit::Count,
        MetricAggregation::RowCount,
        "Nested dynamic-filter runtime evidence rows.",
        None,
        None,
    ),
    metric(
        "native_source_read_runtime_rows",
        MetricUnit::Count,
        MetricAggregation::RowCount,
        "Nested source-read runtime evidence rows.",
        None,
        None,
    ),
    metric(
        "peak_device_memory_bytes",
        MetricUnit::DeviceBytes,
        MetricAggregation::Peak,
        "Backward-compatible alias for resident_dataframe_peak_bytes.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "resident_dataframe_peak_bytes",
        MetricUnit::DeviceBytes,
        MetricAggregation::Peak,
        "Peak bytes retained by resident cudf DataFrames.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "resident_dataframe_peak_bytes_observed",
        MetricUnit::Boolean,
        MetricAggregation::Last,
        "Whether resident_dataframe_peak_bytes was observed.",
        None,
        None,
    ),
    metric(
        "allocator_high_water_bytes",
        MetricUnit::DeviceBytes,
        MetricAggregation::Peak,
        "cuDF allocator high-water bytes when reported by lower layers.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "allocator_high_water_bytes_observed",
        MetricUnit::Boolean,
        MetricAggregation::Last,
        "Whether allocator_high_water_bytes was observed.",
        None,
        None,
    ),
    metric(
        "source_chunks_planned",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Source chunks planned by native source execution.",
        None,
        None,
    ),
    metric(
        "source_chunks_attempted",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Source chunk attempts including retries.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "source_chunks_committed",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Source chunks committed successfully.",
        None,
        None,
    ),
    metric(
        "source_chunks_retried",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Source chunks retried.",
        Some(MetricDirection::LowerIsBetter),
        Some("0"),
    ),
    metric(
        "source_read_prefetches_started",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Source-read prefetches started.",
        None,
        None,
    ),
    metric(
        "source_read_prefetches_completed",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Source-read prefetches completed.",
        None,
        None,
    ),
    metric(
        "source_read_prefetches_skipped",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Source-read prefetches skipped.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "source_read_prefetches_abandoned",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Source-read prefetches abandoned.",
        Some(MetricDirection::LowerIsBetter),
        Some("0"),
    ),
    metric(
        "row_groups_planned",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Row groups planned across source chunks.",
        None,
        None,
    ),
    metric(
        "row_groups_committed",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Row groups committed across source chunks.",
        None,
        None,
    ),
    metric(
        "partial_aggregate_count",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Partial aggregate tasks executed.",
        None,
        None,
    ),
    metric(
        "partial_aggregate_input_rows",
        MetricUnit::Rows,
        MetricAggregation::Sum,
        "Rows consumed by partial aggregates.",
        None,
        None,
    ),
    metric(
        "partial_aggregate_rows",
        MetricUnit::Rows,
        MetricAggregation::Sum,
        "Rows produced by partial aggregates.",
        None,
        None,
    ),
    metric(
        "partial_aggregate_retained_bytes",
        MetricUnit::DeviceBytes,
        MetricAggregation::Peak,
        "Peak bytes retained by partial aggregate outputs.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "final_merge_attempts",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Final aggregate merge attempts.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "final_merge_levels",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Final aggregate merge levels.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "final_merge_max_fan_in",
        MetricUnit::Count,
        MetricAggregation::Peak,
        "Largest final merge fan-in.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "compiled_pipeline_attempts",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Compiled-pipeline execution attempts admitted before runtime.",
        None,
        None,
    ),
    metric(
        "compiled_pipeline_tasks_executed",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Compiled-pipeline tasks executed by the scheduler.",
        None,
        None,
    ),
    metric(
        "compiled_pipeline_host_arrow_sinks",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Host Arrow sink boundaries materialized by compiled pipelines.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "parquet_files",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Parquet files observed by source reads.",
        None,
        None,
    ),
    metric(
        "parquet_bytes_known",
        MetricUnit::ParquetBytes,
        MetricAggregation::Sum,
        "Known Parquet file bytes.",
        None,
        None,
    ),
    metric(
        "row_groups_selected",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Row groups selected by source reads.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "read_columns",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Physical read columns selected by source reads.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "retry_count",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Native execution retries.",
        Some(MetricDirection::LowerIsBetter),
        Some("0"),
    ),
    metric(
        "retry_resource_exhausted_count",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Retries caused by lower-level resource exhaustion.",
        Some(MetricDirection::LowerIsBetter),
        Some("0"),
    ),
    metric(
        "dynamic_filter_produced_count",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Dynamic-filter payloads produced.",
        Some(MetricDirection::HigherIsBetter),
        None,
    ),
    metric(
        "dynamic_filter_skipped_count",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Dynamic-filter routes skipped without a usable payload.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "dynamic_filter_applied_count",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Dynamic-filter payloads applied to runtime consumers.",
        Some(MetricDirection::HigherIsBetter),
        None,
    ),
    metric(
        "dynamic_filter_row_groups_pruned",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Row groups pruned by dynamic filters.",
        Some(MetricDirection::HigherIsBetter),
        None,
    ),
    metric(
        "dynamic_filter_source_bytes_pruned",
        MetricUnit::ParquetBytes,
        MetricAggregation::Sum,
        "Estimated source bytes pruned by dynamic filters.",
        Some(MetricDirection::HigherIsBetter),
        None,
    ),
    metric(
        "dynamic_filter_reader_predicate_rows_before",
        MetricUnit::Rows,
        MetricAggregation::Sum,
        "Source rows selected before dynamic reader predicates.",
        None,
        None,
    ),
    metric(
        "dynamic_filter_reader_predicate_rows_after",
        MetricUnit::Rows,
        MetricAggregation::Sum,
        "Source rows materialized after dynamic reader predicates.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "dynamic_filter_reader_predicate_rows_filtered",
        MetricUnit::Rows,
        MetricAggregation::Sum,
        "Source rows filtered by dynamic reader predicates.",
        Some(MetricDirection::HigherIsBetter),
        None,
    ),
    metric(
        "dynamic_filter_post_decode_rows_before",
        MetricUnit::Rows,
        MetricAggregation::Sum,
        "Rows before post-decode dynamic filters.",
        None,
        None,
    ),
    metric(
        "dynamic_filter_post_decode_rows_after",
        MetricUnit::Rows,
        MetricAggregation::Sum,
        "Rows after post-decode dynamic filters.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "dynamic_filter_post_decode_rows_filtered",
        MetricUnit::Rows,
        MetricAggregation::Sum,
        "Rows filtered by post-decode dynamic filters.",
        Some(MetricDirection::HigherIsBetter),
        None,
    ),
    metric(
        "dynamic_filter_source_post_decode_rows_filtered",
        MetricUnit::Rows,
        MetricAggregation::Sum,
        "Rows filtered by source-adjacent post-decode dynamic filters.",
        Some(MetricDirection::HigherIsBetter),
        None,
    ),
    metric(
        "dynamic_filter_filter_post_decode_rows_filtered",
        MetricUnit::Rows,
        MetricAggregation::Sum,
        "Rows filtered by filter-operator post-decode dynamic filters.",
        Some(MetricDirection::HigherIsBetter),
        None,
    ),
    metric(
        "dynamic_filter_join_probe_post_decode_rows_filtered",
        MetricUnit::Rows,
        MetricAggregation::Sum,
        "Rows filtered by hash-join-probe post-decode dynamic filters.",
        Some(MetricDirection::HigherIsBetter),
        None,
    ),
    metric(
        "hash_join_build_count",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Reusable cuDF hash-join artifacts built.",
        None,
        None,
    ),
    metric(
        "filtered_join_build_count",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "Reusable cuDF filtered-join artifacts built.",
        None,
        None,
    ),
    metric(
        "one_shot_join_count",
        MetricUnit::Count,
        MetricAggregation::Sum,
        "One-shot keyed equality joins executed.",
        None,
        None,
    ),
    metric(
        "hash_join_hash_table_bytes",
        MetricUnit::DeviceBytes,
        MetricAggregation::Sum,
        "Device bytes retained by reusable hash-join build artifacts.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "filtered_join_hash_table_bytes",
        MetricUnit::DeviceBytes,
        MetricAggregation::Sum,
        "Device bytes retained by reusable filtered-join build artifacts.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "filtered_join_probe_state_bytes",
        MetricUnit::DeviceBytes,
        MetricAggregation::Sum,
        "Device bytes retained by filtered-join probe states.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "mixed_join_size_data_bytes",
        MetricUnit::DeviceBytes,
        MetricAggregation::Sum,
        "Device bytes retained by mixed join size-data states.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "one_shot_join_index_bytes",
        MetricUnit::DeviceBytes,
        MetricAggregation::Sum,
        "Device bytes retained by one-shot join index maps.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "one_shot_join_materialization_bytes",
        MetricUnit::DeviceBytes,
        MetricAggregation::Sum,
        "Reservation bytes requested for one-shot join output materialization.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "one_shot_join_output_bytes",
        MetricUnit::DeviceBytes,
        MetricAggregation::Sum,
        "Observed device bytes of one-shot join output frames.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "join_gather_map_bytes",
        MetricUnit::DeviceBytes,
        MetricAggregation::Sum,
        "Device bytes retained by join gather maps.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "native_aggregate_strategy_rows",
        MetricUnit::Count,
        MetricAggregation::RowCount,
        "Nested aggregate strategy decision rows.",
        None,
        None,
    ),
    metric(
        "native_join_strategy_rows",
        MetricUnit::Count,
        MetricAggregation::RowCount,
        "Nested join strategy decision rows.",
        None,
        None,
    ),
    metric(
        "source_metadata_load_time",
        MetricUnit::Nanos,
        MetricAggregation::Sum,
        "Time spent loading source metadata.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "source_read_queue_wait_time",
        MetricUnit::Nanos,
        MetricAggregation::Sum,
        "Time spent waiting in the source-read queue.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "parquet_read_time",
        MetricUnit::Nanos,
        MetricAggregation::Sum,
        "Time spent inside Parquet read calls.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "source_read_time",
        MetricUnit::Nanos,
        MetricAggregation::Sum,
        "Time spent in source-read orchestration.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "operator_time",
        MetricUnit::Nanos,
        MetricAggregation::Sum,
        "Time spent in non-source operators.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "chunk_operator_time",
        MetricUnit::Nanos,
        MetricAggregation::Sum,
        "Time spent in per-chunk operators.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "final_merge_time",
        MetricUnit::Nanos,
        MetricAggregation::Sum,
        "Time spent in final merge operators.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "final_sort_time",
        MetricUnit::Nanos,
        MetricAggregation::Sum,
        "Time spent in final sort operators.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
    metric(
        "materialization_time",
        MetricUnit::Nanos,
        MetricAggregation::Sum,
        "Time spent materializing final outputs.",
        Some(MetricDirection::LowerIsBetter),
        None,
    ),
];

impl QueryMetrics {
    /// Returns the query-metric descriptor catalog.
    pub fn descriptors() -> &'static [MetricDescriptor] {
        QUERY_METRIC_DESCRIPTORS
    }
}