scovich commented on code in PR #8322:
URL: https://github.com/apache/arrow-rs/pull/8322#discussion_r2341405217
##########
parquet-variant-compute/src/variant_get/output/row_builder.rs:
##########
@@ -32,146 +32,42 @@ pub(crate) fn make_shredding_row_builder<'a>(
data_type: Option<&'a datatypes::DataType>,
cast_options: &'a CastOptions,
) -> Result<Box<dyn VariantShreddingRowBuilder + 'a>> {
- use arrow::array::PrimitiveBuilder;
use datatypes::{
Float16Type, Float32Type, Float64Type, Int16Type, Int32Type,
Int64Type, Int8Type,
};
- // support non-empty paths (field access) and some empty path cases
- if path.is_empty() {
- return match data_type {
- Some(datatypes::DataType::Int8) => {
- let builder = PrimitiveVariantShreddingRowBuilder {
- builder: PrimitiveBuilder::<Int8Type>::new(),
- cast_options,
- };
- Ok(Box::new(builder))
- }
- Some(datatypes::DataType::Int16) => {
- let builder = PrimitiveVariantShreddingRowBuilder {
- builder: PrimitiveBuilder::<Int16Type>::new(),
- cast_options,
- };
- Ok(Box::new(builder))
- }
- Some(datatypes::DataType::Int32) => {
- let builder = PrimitiveVariantShreddingRowBuilder {
- builder: PrimitiveBuilder::<Int32Type>::new(),
- cast_options,
- };
- Ok(Box::new(builder))
- }
- Some(datatypes::DataType::Int64) => {
- let builder = PrimitiveVariantShreddingRowBuilder {
- builder: PrimitiveBuilder::<Int64Type>::new(),
- cast_options,
- };
- Ok(Box::new(builder))
- }
- Some(datatypes::DataType::Float16) => {
- let builder = PrimitiveVariantShreddingRowBuilder {
- builder: PrimitiveBuilder::<Float16Type>::new(),
- cast_options,
- };
- Ok(Box::new(builder))
- }
- Some(datatypes::DataType::Float32) => {
- let builder = PrimitiveVariantShreddingRowBuilder {
- builder: PrimitiveBuilder::<Float32Type>::new(),
- cast_options,
- };
- Ok(Box::new(builder))
- }
- Some(datatypes::DataType::Float64) => {
- let builder = PrimitiveVariantShreddingRowBuilder {
- builder: PrimitiveBuilder::<Float64Type>::new(),
- cast_options,
- };
- Ok(Box::new(builder))
- }
- None => {
- // Return VariantArrayBuilder for VariantArray output
- let builder = VariantArrayShreddingRowBuilder::new(16);
- Ok(Box::new(builder))
- }
- _ => Err(ArrowError::NotYetImplemented(format!(
- "variant_get with empty path and data_type={:?} not yet
implemented",
- data_type
- ))),
- };
- }
-
- // Non-empty paths: field access functionality
- // Helper macro to reduce duplication when wrapping builders with path
functionality
- macro_rules! wrap_with_path {
- ($inner_builder:expr) => {
- Ok(Box::new(VariantPathRowBuilder {
- builder: $inner_builder,
- path,
- }) as Box<dyn VariantShreddingRowBuilder + 'a>)
- };
- }
-
- match data_type {
+ let builder = match data_type {
+ // If no data type was requested, build a VariantArray that preserves
existing shredding.
Review Comment:
```suggestion
// If no data type was requested, build an unshredded VariantArray.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]