Skip to main content

timeseries_table_format/table/operations/coverage/
error.rs

1use snafu::{Backtrace, Snafu};
2
3use crate::{
4    coverage::{
5        EntityIdentityError, index_interval::IndexIntervalMappingError, io::CoverageSidecarError,
6    },
7    metadata::{index::IndexValueError, schema_compat::SchemaCompatibilityError},
8};
9
10/// Errors from table coverage queries and read-only coverage recovery.
11#[derive(Debug, Snafu)]
12#[snafu(visibility(pub(super)))]
13#[non_exhaustive]
14pub enum CoverageQueryError {
15    /// The requested half-open ordered-index range is invalid.
16    #[snafu(display("Invalid coverage query range: {source}"))]
17    InvalidRange {
18        /// Complete range validation error.
19        source: IndexValueError,
20        /// Backtrace captured at the coverage query boundary.
21        backtrace: Box<Backtrace>,
22    },
23
24    /// An ordered value could not be mapped to its index interval ID.
25    #[snafu(display("Coverage query index interval mapping failed: {source}"))]
26    IndexIntervalMapping {
27        /// Complete interval mapping error.
28        source: IndexIntervalMappingError,
29        /// Backtrace captured at the coverage query boundary.
30        backtrace: Box<Backtrace>,
31    },
32
33    /// Constructing a canonical entity identity failed.
34    #[snafu(display("Invalid coverage query entity identity: {source}"))]
35    InvalidEntityIdentity {
36        /// Complete entity identity construction error.
37        source: EntityIdentityError,
38        /// Backtrace captured at the coverage query boundary.
39        backtrace: Box<Backtrace>,
40    },
41
42    /// The query identity is incompatible with the table schema.
43    #[snafu(display("Coverage query schema compatibility error: {source}"))]
44    SchemaCompatibility {
45        /// Complete schema compatibility error.
46        #[snafu(source(from(SchemaCompatibilityError, Box::new)), backtrace)]
47        source: Box<SchemaCompatibilityError>,
48    },
49
50    /// An identity-free query was used on an entity-aware table.
51    #[snafu(display(
52        "Entity identity is required for coverage queries; configured entity columns: {entity_columns:?}"
53    ))]
54    EntityIdentityRequired {
55        /// Entity columns that require values from the caller.
56        entity_columns: Vec<String>,
57        /// Backtrace captured at the coverage query boundary.
58        backtrace: Box<Backtrace>,
59    },
60
61    /// An entity-aware query was used on a table with global coverage.
62    #[snafu(display("Table has no configured entity columns"))]
63    EntityIdentityNotConfigured {
64        /// Backtrace captured at the coverage query boundary.
65        backtrace: Box<Backtrace>,
66    },
67
68    /// A required entity column has no caller-provided value.
69    #[snafu(display("Missing entity identity component for column {column}"))]
70    MissingEntityIdentityColumn {
71        /// Configured entity column missing from the caller input.
72        column: String,
73        /// Backtrace captured at the coverage query boundary.
74        backtrace: Box<Backtrace>,
75    },
76
77    /// Caller input repeats one entity column.
78    #[snafu(display("Duplicate entity identity component for column {column}"))]
79    DuplicateEntityIdentityColumn {
80        /// Repeated entity column name.
81        column: String,
82        /// Backtrace captured at the coverage query boundary.
83        backtrace: Box<Backtrace>,
84    },
85
86    /// Caller input contains a column outside the entity identity.
87    #[snafu(display("Unexpected entity identity component for column {column}"))]
88    UnexpectedEntityIdentityColumn {
89        /// Unknown entity column name.
90        column: String,
91        /// Backtrace captured at the coverage query boundary.
92        backtrace: Box<Backtrace>,
93    },
94
95    /// Reading a table coverage snapshot sidecar failed.
96    #[snafu(display("Failed to read table coverage sidecar {coverage_path}: {source}"))]
97    CoverageSnapshotRead {
98        /// Table-relative sidecar path.
99        coverage_path: String,
100        /// Complete sidecar error, including storage or codec detail.
101        #[snafu(source(from(CoverageSidecarError, Box::new)), backtrace)]
102        source: Box<CoverageSidecarError>,
103    },
104
105    /// An existing segment has no coverage sidecar path.
106    #[snafu(display("Existing segment {segment_path} is missing coverage_path"))]
107    ExistingSegmentMissingCoverageMetadata {
108        /// Canonical segment path missing a coverage path.
109        segment_path: String,
110        /// Backtrace captured at the coverage query boundary.
111        backtrace: Box<Backtrace>,
112    },
113
114    /// Reading a segment sidecar failed during read-only recovery.
115    #[snafu(display(
116        "Failed to recover table coverage from segment {segment_path} sidecar {coverage_path}: {source}"
117    ))]
118    SegmentCoverageSidecarRead {
119        /// Canonical segment path.
120        segment_path: String,
121        /// Table-relative sidecar path.
122        coverage_path: String,
123        /// Complete sidecar error, including storage or codec detail.
124        #[snafu(source(from(CoverageSidecarError, Box::new)), backtrace)]
125        source: Box<CoverageSidecarError>,
126    },
127
128    /// Table state has segments but no coverage snapshot pointer.
129    #[snafu(display("Table has segments but no table coverage snapshot pointer"))]
130    MissingTableCoveragePointer {
131        /// Backtrace captured at the coverage query boundary.
132        backtrace: Box<Backtrace>,
133    },
134}