Skip to content

Commit

Permalink
make arrow map compatible with parquet map
Browse files Browse the repository at this point in the history
  • Loading branch information
ion-elgreco committed Aug 3, 2024
1 parent 1258a88 commit dd4118c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kernel/src/engine/arrow_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ use crate::error::Error;
use crate::schema::{ArrayType, DataType, MapType, PrimitiveType, StructField, StructType};

pub(crate) const LIST_ARRAY_ROOT: &str = "item";
pub(crate) const MAP_ROOT_DEFAULT: &str = "key_value";
pub(crate) const MAP_KEY_DEFAULT: &str = "key";
pub(crate) const MAP_VALUE_DEFAULT: &str = "value";

impl TryFrom<&StructType> for ArrowSchema {
type Error = ArrowError;
Expand Down Expand Up @@ -61,12 +64,12 @@ impl TryFrom<&MapType> for ArrowField {

fn try_from(a: &MapType) -> Result<Self, ArrowError> {
Ok(ArrowField::new(
"entries",
MAP_ROOT_DEFAULT,
ArrowDataType::Struct(
vec![
ArrowField::new("keys", ArrowDataType::try_from(a.key_type())?, false),
ArrowField::new(MAP_KEY_DEFAULT, ArrowDataType::try_from(a.key_type())?, false),
ArrowField::new(
"values",
MAP_VALUE_DEFAULT,
ArrowDataType::try_from(a.value_type())?,
a.value_contains_null(),
),
Expand Down

0 comments on commit dd4118c

Please sign in to comment.