Skip to main content

sorting_parquet_writer/
error.rs

1//! Error type returned by the sorting writers and merge utilities.
2
3use std::io;
4
5use arrow::error::ArrowError;
6use parquet::errors::ParquetError;
7use thiserror::Error;
8
9/// The unified error type produced by this crate.
10///
11/// Wraps the three I/O / format error sources used during sorting and writing
12/// ([`ArrowError`], [`ParquetError`], [`std::io::Error`]) and adds two
13/// crate-specific variants for misconfiguration and an internal invariant
14/// violation.
15#[derive(Debug, Error)]
16pub enum SortingParquetError {
17    /// An error originating from the Arrow compute / array layer.
18    #[error(transparent)]
19    ArrowError(#[from] ArrowError),
20
21    /// An error originating from the Parquet reader/writer layer.
22    #[error(transparent)]
23    ParquetError(#[from] ParquetError),
24
25    /// Returned by `try_new` constructors when the supplied
26    /// [`WriterProperties`](parquet::file::properties::WriterProperties) does
27    /// not have sorting columns configured via
28    /// [`set_sorting_columns`](parquet::file::properties::WriterPropertiesBuilder::set_sorting_columns).
29    #[error("No Sorting Columns Configured")]
30    NoSortingColumnsConfigured,
31
32    /// Returned when a writer operation requires the internal row converter
33    /// but the writer has already consumed it as part of a finalize step.
34    #[error("Writer is already closed")]
35    WriterClosed,
36
37    /// An error reading from or writing to a file (run files or the target).
38    #[error(transparent)]
39    IoError(#[from] io::Error),
40
41    /// An internal invariant was violated while computing min/max sort keys
42    /// for a merged batch.
43    ///
44    /// Currently surfaces only from
45    /// [`merge_sorted_batches_with_row_converter_returning_extremes`](crate::record_batch::merge_sorted_batches_with_row_converter_returning_extremes)
46    /// when every input batch is empty, so the merge has no rows from which
47    /// to extract a min or max.
48    #[error("Unexpected index out of bounds during sorting")]
49    UnexpectedIndexOutOfBounds,
50}