Skip to content

Commit d7a9a31

Browse files
Support Dictionary types in Arrow Schema to Iceberg Schema conversion (#10)
1 parent e0a591f commit d7a9a31

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

crates/iceberg/src/arrow/schema.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ fn visit_type<V: ArrowSchemaVisitor>(r#type: &DataType, visitor: &mut V) -> Resu
168168
)),
169169
},
170170
DataType::Struct(fields) => visit_struct(fields, visitor),
171+
DataType::Dictionary(_, value_type) => visit_type(value_type, visitor),
171172
other => Err(Error::new(
172173
ErrorKind::DataInvalid,
173174
format!("Cannot visit Arrow data type: {other}"),
@@ -1522,5 +1523,14 @@ mod tests {
15221523
]));
15231524
assert_eq!(arrow_type, type_to_arrow_type(&iceberg_type).unwrap());
15241525
}
1526+
1527+
// test dictionary type
1528+
{
1529+
let arrow_type =
1530+
DataType::Dictionary(Box::new(DataType::Int8), Box::new(DataType::Utf8));
1531+
let iceberg_type = Type::Primitive(PrimitiveType::String);
1532+
assert_eq!(iceberg_type, arrow_type_to_type(&arrow_type).unwrap());
1533+
assert_eq!(DataType::Utf8, type_to_arrow_type(&iceberg_type).unwrap());
1534+
}
15251535
}
15261536
}

0 commit comments

Comments
 (0)