Skip to main content

timeseries_table_core/metadata/
time_column.rs

1//! Errors related to discovering and validating timestamp columns in schemas.
2//!
3//! When processing Parquet or Arrow data, the crate needs to locate and validate
4//! the timestamp column specified in the table's index spec. This module provides
5//! error types for the common failure modes:
6//! - Column not found in schema.
7//! - Column uses an unsupported Parquet physical/logical type pair.
8//! - Column uses an unsupported Arrow data type.
9//!
10//! These errors are used by segment metadata validation, coverage computation,
11//! and schema introspection logic.
12
13use snafu::Snafu;
14
15/// Errors that can occur when locating or validating a timestamp column.
16///
17/// A timestamp column is required by the table's time index specification to
18/// enable time-series range queries and coverage computation. This enum captures
19/// the various ways that validation can fail:
20/// - The column may not exist in the schema.
21/// - The column may exist but use a Parquet type that is not supported.
22/// - The column may exist but use an Arrow type that is not supported.
23#[derive(Debug, Snafu, Clone, PartialEq, Eq)]
24pub enum TimeColumnError {
25    /// The specified time column was not found in the schema.
26    ///
27    /// This typically indicates either a configuration mismatch (the table's
28    /// index spec references a column that doesn't exist in the data) or
29    /// a schema evolution issue (the column was removed in a later segment).
30    #[snafu(display("Time column {column} not found in schema"))]
31    Missing {
32        /// The name of the time column that was expected but not found.
33        column: String,
34    },
35
36    /// The time column uses a Parquet physical/logical type pair that is not supported.
37    ///
38    /// For example, the column might use an integer or string type instead of
39    /// a timestamp type, or it might use a timestamp variant (e.g., nanoseconds)
40    /// that the crate does not currently support.
41    #[snafu(display(
42        "Unsupported physical type for time column {column}: physical={physical} logical={logical}"
43    ))]
44    UnsupportedParquetType {
45        /// The name of the time column.
46        column: String,
47        /// The Parquet physical type (e.g., INT64, BYTE_ARRAY).
48        physical: String,
49        /// The Parquet logical type annotation, if present (e.g., TIMESTAMP, STRING).
50        logical: String,
51    },
52
53    /// The time column uses an Arrow data type that is not supported.
54    ///
55    /// This can occur when converting from Parquet to Arrow or when working
56    /// directly with Arrow data. Supported types typically include timestamp
57    /// variants with microsecond or millisecond precision.
58    #[snafu(display("Unsupported arrow type for time column {column}: {datatype}"))]
59    UnsupportedArrowType {
60        /// The name of the time column.
61        column: String,
62        /// The Arrow data type that is not supported (e.g., "String", "Int32").
63        datatype: String,
64    },
65}