Skip to content

Commit 1cf1862

Browse files
committed
More tests and docs
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
1 parent ef8eaf1 commit 1cf1862

4 files changed

Lines changed: 476 additions & 51 deletions

File tree

encodings/parquet-variant/src/array.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,18 @@ use vortex_error::VortexResult;
2323
use vortex_error::vortex_ensure;
2424
use vortex_mask::Mask;
2525

26-
/// An array encoding that stores variant data in the Parquet Variant binary format.
26+
/// Array storage for Arrow's canonical `arrow.parquet.variant` extension type.
2727
///
28-
/// Contains up to three children following the Arrow Parquet Variant canonical extension type:
29-
/// - `metadata` (always present): binary array with variant type information
30-
/// - `value` (optional): binary array with un-shredded serialized variant values
31-
/// - `typed_value` (optional): array of any type with shredded column data
28+
/// `ParquetVariantArray` preserves semi-structured data stored as Parquet Variant values in a
29+
/// lossless form and supports both unshredded and shredded layouts. Its storage matches the
30+
/// canonical extension type contract:
31+
/// - `metadata` is always present and non-nullable
32+
/// - `value` stores unshredded variant bytes when present
33+
/// - `typed_value` stores shredded data when present
3234
///
33-
/// At least one of `value` or `typed_value` must be present.
34-
/// The `typed_value` supports full recursive shredding — it can be a primitive, list, or struct
35-
/// where nested struct/list elements themselves contain value/typed_value children.
35+
/// At least one of `value` or `typed_value` must be present. `typed_value` may be a primitive,
36+
/// list, or struct, with nested shredded children following the same recursive rules as the
37+
/// Arrow canonical extension type docs.
3638
#[derive(Clone, Debug)]
3739
pub struct ParquetVariantArray {
3840
pub(crate) dtype: DType,
@@ -44,7 +46,7 @@ pub struct ParquetVariantArray {
4446
}
4547

4648
impl ParquetVariantArray {
47-
/// Creates a new ParquetVariantArray.
49+
/// Creates a Parquet Variant array that follows the canonical extension storage layout.
4850
pub fn try_new(
4951
metadata: ArrayRef,
5052
value: Option<ArrayRef>,
@@ -53,7 +55,7 @@ impl ParquetVariantArray {
5355
Self::try_new_with_validity(Validity::AllValid, metadata, value, typed_value)
5456
}
5557

56-
/// Creates a new ParquetVariantArray with explicit parent validity.
58+
/// Creates a Parquet Variant array with explicit outer validity.
5759
pub fn try_new_with_validity(
5860
validity: Validity,
5961
metadata: ArrayRef,

encodings/parquet-variant/src/lib.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

4-
//! This crate exposes a Vortex encoding that supports variant arrays, encoded as parquet's
5-
//! [Variant encoding], in order to allow for zero-copy export to Arrow's new
6-
//! [canonical extension type].
4+
//! Vortex support for Arrow's canonical `arrow.parquet.variant` extension type.
75
//!
8-
//! The encoding follows the Arrow Parquet Variant canonical extension type structure:
9-
//! - `metadata` (binary, required): type information for arrays/objects, field names and offsets
10-
//! - `value` (binary, optional): un-shredded serialized variant values
11-
//! - `typed_value` (any type, optional): shredded column data with a known type
6+
//! This encoding provides a lossless representation of semi-structured data stored as
7+
//! [Parquet Variant values] inside Arrow columns. It also supports [shredded variant values],
8+
//! allowing systems to pass variant-encoded data around without special handling unless they
9+
//! need to inspect the encoded contents directly.
1210
//!
13-
//! At least one of `value` or `typed_value` must be present. The `typed_value` child supports
14-
//! full recursive shredding — it can be a primitive type, a list (whose elements are variant
15-
//! nodes with value/typed_value), or a struct (whose fields are variant nodes).
11+
//! The storage type is a `Struct` that follows the Arrow canonical extension contract:
12+
//! - `metadata` (required): a non-nullable binary child containing variant metadata
13+
//! - `value` (optional): a binary child containing unshredded variant bytes
14+
//! - `typed_value` (optional): a shredded child with a primitive, list, or struct layout
1615
//!
17-
//! [Variant encoding]: https://parquet.apache.org/docs/file-format/types/variantencoding/
18-
//! [canonical extension type]: https://arrow.apache.org/docs/format/CanonicalExtensions.html#parquet-variant
16+
//! At least one of `value` or `typed_value` must be present. Nested shredded values recurse
17+
//! through the same `value` and `typed_value` structure described by the canonical extension
18+
//! type documentation.
19+
//!
20+
//! See the Arrow canonical extension docs for the storage rules, and the Parquet format
21+
//! specification for the binary representation.
22+
//!
23+
//! [Parquet Variant values]: https://github.com/apache/parquet-format/blob/master/VariantEncoding.md
24+
//! [shredded variant values]: https://github.com/apache/parquet-format/blob/master/VariantShredding.md
25+
//! [Arrow canonical extension type]: https://arrow.apache.org/docs/format/CanonicalExtensions.html#parquet-variant
1926
2027
mod array;
2128
mod operations;

0 commit comments

Comments
 (0)