chronix_query/error.rs
1//! Query engine error types.
2
3use thiserror::Error;
4
5/// Query engine errors.
6#[derive(Debug, Error)]
7pub enum QueryError {
8 /// Measurement not found in the schema registry.
9 #[error("Measurement not found: '{0}'")]
10 MeasurementNotFound(String),
11
12 /// Field not found in the measurement schema.
13 #[error("Field '{field}' not found in measurement '{measurement}'")]
14 FieldNotFound {
15 /// Measurement name.
16 measurement: String,
17 /// Field name that was not found.
18 field: String,
19 },
20
21 /// Invalid time range (start > end).
22 #[error("Invalid time range: start ({start}) > end ({end})")]
23 InvalidTimeRange {
24 /// Start timestamp.
25 start: i64,
26 /// End timestamp.
27 end: i64,
28 },
29
30 /// Query validation error.
31 #[error("Query validation error: {0}")]
32 Validation(String),
33
34 /// Segment read error.
35 #[error("Segment error: {0}")]
36 Segment(#[from] chronix_engine::segment::SegmentError),
37
38 /// Arrow computation error.
39 #[error("Arrow error: {0}")]
40 Arrow(#[from] arrow::error::ArrowError),
41
42 /// Index error.
43 #[error("Index error: {0}")]
44 Index(#[from] chronix_engine::index::IndexError),
45
46 /// I/O error.
47 #[error("I/O error: {0}")]
48 Io(#[from] std::io::Error),
49
50 /// Per-query memory budget exceeded.
51 ///
52 /// Returned when a query operator attempts to allocate more memory
53 /// than the configured per-query budget allows. This prevents
54 /// individual queries from causing OOM on the server.
55 #[error(
56 "Query memory budget exceeded: requested {requested} bytes, \
57 already allocated {allocated} of {budget} bytes"
58 )]
59 QueryMemoryExceeded {
60 /// Bytes requested in this allocation.
61 requested: usize,
62 /// Bytes already allocated by this query.
63 allocated: usize,
64 /// Total budget for this query.
65 budget: usize,
66 },
67}
68
69/// A specialized `Result` type for query operations.
70pub type Result<T> = std::result::Result<T, QueryError>;