Skip to content

Commit f401792

Browse files
authored
arrow -> vortex for dict arrays (#5316)
Signed-off-by: Onur Satici <[email protected]>
1 parent 956f5c2 commit f401792

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

vortex-array/src/arrow/convert.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use vortex_error::{VortexExpect as _, vortex_panic};
2929
use vortex_scalar::i256;
3030

3131
use crate::arrays::{
32-
BoolArray, DecimalArray, FixedSizeListArray, ListArray, ListViewArray, NullArray,
32+
BoolArray, DecimalArray, DictArray, FixedSizeListArray, ListArray, ListViewArray, NullArray,
3333
PrimitiveArray, StructArray, TemporalArray, VarBinArray, VarBinViewArray,
3434
};
3535
use crate::arrow::FromArrowArray;
@@ -492,6 +492,36 @@ impl FromArrowArray<&dyn ArrowArray> for ArrayRef {
492492
DataType::Decimal256(..) => {
493493
Self::from_arrow(array.as_primitive::<Decimal256Type>(), nullable)
494494
}
495+
DataType::Dictionary(key_type, _) => match key_type.as_ref() {
496+
DataType::Int8 => {
497+
DictArray::from_arrow(array.as_dictionary::<Int8Type>(), nullable).into_array()
498+
}
499+
DataType::Int16 => {
500+
DictArray::from_arrow(array.as_dictionary::<Int16Type>(), nullable).into_array()
501+
}
502+
DataType::Int32 => {
503+
DictArray::from_arrow(array.as_dictionary::<Int32Type>(), nullable).into_array()
504+
}
505+
DataType::Int64 => {
506+
DictArray::from_arrow(array.as_dictionary::<Int64Type>(), nullable).into_array()
507+
}
508+
DataType::UInt8 => {
509+
DictArray::from_arrow(array.as_dictionary::<UInt8Type>(), nullable).into_array()
510+
}
511+
DataType::UInt16 => {
512+
DictArray::from_arrow(array.as_dictionary::<UInt16Type>(), nullable)
513+
.into_array()
514+
}
515+
DataType::UInt32 => {
516+
DictArray::from_arrow(array.as_dictionary::<UInt32Type>(), nullable)
517+
.into_array()
518+
}
519+
DataType::UInt64 => {
520+
DictArray::from_arrow(array.as_dictionary::<UInt64Type>(), nullable)
521+
.into_array()
522+
}
523+
key_dt => vortex_panic!("Unsupported dictionary key type: {key_dt}"),
524+
},
495525
dt => vortex_panic!("Array encoding not implemented for Arrow data type {dt}"),
496526
}
497527
}

0 commit comments

Comments
 (0)