Skip to content

Commit 43c84fc

Browse files
alambCopilotscovich
authored
[Variant] Improve documentation and make kernels consistent (#8536)
# Which issue does this PR close? We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. - Closes #8531 - Closes #8532 # Rationale for this change Basically, I was confused about the casting / conversion functions available so I want to improve the documentation # What changes are included in this PR? 1. Add documentation, improve other docs 2. Remove `pub` crates in favor of exporting only the functions/ structs needed # Are these changes tested? Yes by CI If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? # Are there any user-facing changes? If there are user-facing changes then we may require documentation to be updated before approving the PR. If there are any breaking changes to public APIs, please call them out. --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Ryan Johnson <[email protected]>
1 parent 9d03e41 commit 43c84fc

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

parquet-variant-compute/benches/variant_kernels.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ use arrow::array::{Array, ArrayRef, StringArray};
1919
use arrow::util::test_util::seedable_rng;
2020
use criterion::{Criterion, criterion_group, criterion_main};
2121
use parquet_variant::{Variant, VariantBuilder};
22-
use parquet_variant_compute::variant_get::{GetOptions, variant_get};
23-
use parquet_variant_compute::{VariantArray, VariantArrayBuilder, json_to_variant};
22+
use parquet_variant_compute::{
23+
GetOptions, VariantArray, VariantArrayBuilder, json_to_variant, variant_get,
24+
};
2425
use rand::Rng;
2526
use rand::SeedableRng;
2627
use rand::distr::Alphanumeric;

parquet-variant-compute/src/cast_to_variant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use arrow_schema::ArrowError;
3434
/// ```
3535
/// # use arrow::array::{Array, ArrayRef, Int64Array};
3636
/// # use parquet_variant::Variant;
37-
/// # use parquet_variant_compute::cast_to_variant::cast_to_variant;
37+
/// # use parquet_variant_compute::cast_to_variant;
3838
/// // input is an Int64Array, which will be cast to a VariantArray
3939
/// let input = Int64Array::from(vec![Some(1), None, Some(3)]);
4040
/// let result = cast_to_variant(&input).unwrap();

parquet-variant-compute/src/lib.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@
2020
//! ## Main APIs
2121
//! - [`VariantArray`] : Represents an array of `Variant` values.
2222
//! - [`VariantArrayBuilder`]: For building [`VariantArray`]
23-
//! - [`json_to_variant`]: Function to convert a batch of JSON strings to a `VariantArray`.
24-
//! - [`variant_to_json`]: Function to convert a `VariantArray` to a batch of JSON strings.
25-
//! - [`mod@cast_to_variant`]: Module to cast other Arrow arrays to `VariantArray`.
26-
//! - [`variant_get`]: Module to get values from a `VariantArray` using a specified [`VariantPath`]
23+
//!
24+
//! # Compute Kernels
25+
//! - [`json_to_variant()`]: Function to convert Arrays of JSON strings to a `VariantArray`.
26+
//! - [`variant_to_json()`]: Function to convert a `VariantArray` to arrays of JSON strings.
27+
//! - [`cast_to_variant()`]: Cast Arrow arrays to `VariantArray`.
28+
//! - [`variant_get()`]: Convert `VariantArray` (or an inner path) to a strongly-typed Arrow array.
29+
//! - [`shred_variant()`]: Shred a `VariantArray` according to the provided shredding schema
30+
//! - [`unshred_variant()`]: Unshred a `VariantArray` to pure binary variant.
2731
//!
2832
//! ## 🚧 Work In Progress
2933
//!
@@ -36,15 +40,15 @@
3640
//! [Variant issue]: https://github.com/apache/arrow-rs/issues/6736
3741
3842
mod arrow_to_variant;
39-
pub mod cast_to_variant;
43+
mod cast_to_variant;
4044
mod from_json;
4145
mod shred_variant;
4246
mod to_json;
4347
mod type_conversion;
4448
mod unshred_variant;
4549
mod variant_array;
4650
mod variant_array_builder;
47-
pub mod variant_get;
51+
mod variant_get;
4852
mod variant_to_arrow;
4953

5054
pub use variant_array::{BorrowedShreddingState, ShreddingState, VariantArray, VariantType};
@@ -56,3 +60,4 @@ pub use shred_variant::shred_variant;
5660
pub use to_json::variant_to_json;
5761
pub use type_conversion::CastOptions;
5862
pub use unshred_variant::unshred_variant;
63+
pub use variant_get::{GetOptions, variant_get};

parquet/src/variant.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,11 @@
2222
//! Note: Requires the `variant_experimental` feature of the `parquet` crate to be enabled.
2323
//!
2424
//! # Features
25-
//! * [`Variant`] represents variant value, which can be an object, list, or primitive.
26-
//! * [`VariantBuilder`] for building `Variant` values.
27-
//! * [`VariantArray`] for representing a column of Variant values.
28-
//! * [`json_to_variant`] and [`variant_to_json`] for converting to/from JSON.
29-
//! * [`cast_to_variant()`] for casting other Arrow arrays to `VariantArray`.
30-
//! * [`VariantType`] Arrow ExtensionType for Parquet Variant logical type.
31-
//! [`variant_get`] to extracting a value by path and functions to convert
32-
//! between `Variant` and JSON.
25+
//! * Representation of [`Variant`], and [`VariantArray`] for working with
26+
//! Variant values (see [`parquet_variant`] for more details)
27+
//! * Kernels for working with arrays of Variant values
28+
//! such as conversion between `Variant` and JSON, and shredding/unshredding
29+
//! (see [`parquet_variant_compute`] for more details)
3330
//!
3431
//! # Example: Writing a Parquet file with Variant column
3532
//! ```rust

0 commit comments

Comments
 (0)