diff --git a/Cargo.lock b/Cargo.lock index 12e6f788..696c4078 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,7 +55,7 @@ checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "arrow-array" version = "51.0.0" -source = "git+https://github.com/apache/arrow-rs.git?rev=c203785ca398b879960bffbd30b988c9728b7c23#c203785ca398b879960bffbd30b988c9728b7c23" +source = "git+https://github.com/apache/arrow-rs.git?rev=d17b2067d637c563eb315571e719807a6f482784#d17b2067d637c563eb315571e719807a6f482784" dependencies = [ "ahash", "arrow-buffer", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "arrow-buffer" version = "51.0.0" -source = "git+https://github.com/apache/arrow-rs.git?rev=c203785ca398b879960bffbd30b988c9728b7c23#c203785ca398b879960bffbd30b988c9728b7c23" +source = "git+https://github.com/apache/arrow-rs.git?rev=d17b2067d637c563eb315571e719807a6f482784#d17b2067d637c563eb315571e719807a6f482784" dependencies = [ "bytes", "half 2.3.1", @@ -80,7 +80,7 @@ dependencies = [ [[package]] name = "arrow-cast" version = "51.0.0" -source = "git+https://github.com/apache/arrow-rs.git?rev=c203785ca398b879960bffbd30b988c9728b7c23#c203785ca398b879960bffbd30b988c9728b7c23" +source = "git+https://github.com/apache/arrow-rs.git?rev=d17b2067d637c563eb315571e719807a6f482784#d17b2067d637c563eb315571e719807a6f482784" dependencies = [ "arrow-array", "arrow-buffer", @@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "arrow-data" version = "51.0.0" -source = "git+https://github.com/apache/arrow-rs.git?rev=c203785ca398b879960bffbd30b988c9728b7c23#c203785ca398b879960bffbd30b988c9728b7c23" +source = "git+https://github.com/apache/arrow-rs.git?rev=d17b2067d637c563eb315571e719807a6f482784#d17b2067d637c563eb315571e719807a6f482784" dependencies = [ "arrow-buffer", "arrow-schema", @@ -111,7 +111,7 @@ dependencies = [ [[package]] name = "arrow-ipc" version = "51.0.0" -source = "git+https://github.com/apache/arrow-rs.git?rev=c203785ca398b879960bffbd30b988c9728b7c23#c203785ca398b879960bffbd30b988c9728b7c23" +source = "git+https://github.com/apache/arrow-rs.git?rev=d17b2067d637c563eb315571e719807a6f482784#d17b2067d637c563eb315571e719807a6f482784" dependencies = [ "arrow-array", "arrow-buffer", @@ -124,12 +124,12 @@ dependencies = [ [[package]] name = "arrow-schema" version = "51.0.0" -source = "git+https://github.com/apache/arrow-rs.git?rev=c203785ca398b879960bffbd30b988c9728b7c23#c203785ca398b879960bffbd30b988c9728b7c23" +source = "git+https://github.com/apache/arrow-rs.git?rev=d17b2067d637c563eb315571e719807a6f482784#d17b2067d637c563eb315571e719807a6f482784" [[package]] name = "arrow-select" version = "51.0.0" -source = "git+https://github.com/apache/arrow-rs.git?rev=c203785ca398b879960bffbd30b988c9728b7c23#c203785ca398b879960bffbd30b988c9728b7c23" +source = "git+https://github.com/apache/arrow-rs.git?rev=d17b2067d637c563eb315571e719807a6f482784#d17b2067d637c563eb315571e719807a6f482784" dependencies = [ "ahash", "arrow-array", @@ -382,9 +382,9 @@ dependencies = [ [[package]] name = "flatbuffers" -version = "23.5.26" +version = "24.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dac53e22462d78c16d64a1cd22371b54cc3fe94aa15e7886a2fa6e5d1ab8640" +checksum = "8add37afff2d4ffa83bc748a70b4b1370984f6980768554182424ef71447c35f" dependencies = [ "bitflags 1.3.2", "rustc_version", @@ -755,7 +755,7 @@ dependencies = [ [[package]] name = "parquet" version = "51.0.0" -source = "git+https://github.com/apache/arrow-rs.git?rev=c203785ca398b879960bffbd30b988c9728b7c23#c203785ca398b879960bffbd30b988c9728b7c23" +source = "git+https://github.com/apache/arrow-rs.git?rev=d17b2067d637c563eb315571e719807a6f482784#d17b2067d637c563eb315571e719807a6f482784" dependencies = [ "ahash", "arrow-array", diff --git a/Cargo.toml b/Cargo.toml index d8ed7a13..ec630086 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,21 +43,21 @@ derive = ["dep:narrow-derive"] uuid = ["dep:uuid"] [dependencies] -arrow-array = { git = "https://github.com/apache/arrow-rs.git", rev = "c203785ca398b879960bffbd30b988c9728b7c23", default-features = false, optional = true } -arrow-buffer = { git = "https://github.com/apache/arrow-rs.git", rev = "c203785ca398b879960bffbd30b988c9728b7c23", default-features = false, optional = true } -arrow-schema = { git = "https://github.com/apache/arrow-rs.git", rev = "c203785ca398b879960bffbd30b988c9728b7c23", default-features = false, optional = true } +arrow-array = { git = "https://github.com/apache/arrow-rs.git", rev = "d17b2067d637c563eb315571e719807a6f482784", default-features = false, optional = true } +arrow-buffer = { git = "https://github.com/apache/arrow-rs.git", rev = "d17b2067d637c563eb315571e719807a6f482784", default-features = false, optional = true } +arrow-schema = { git = "https://github.com/apache/arrow-rs.git", rev = "d17b2067d637c563eb315571e719807a6f482784", default-features = false, optional = true } narrow-derive = { path = "narrow-derive", version = "^0.5.0", optional = true } uuid = { version = "1.8.0", default-features = false, optional = true } [dev-dependencies] -arrow-cast = { git = "https://github.com/apache/arrow-rs.git", rev = "c203785ca398b879960bffbd30b988c9728b7c23", default-features = false, features = [ +arrow-cast = { git = "https://github.com/apache/arrow-rs.git", rev = "d17b2067d637c563eb315571e719807a6f482784", default-features = false, features = [ "prettyprint", ] } bytes = "1.5.0" criterion = { version = "0.5.1", default-features = false } rand = { version = "0.8.5", default-features = false, features = ["small_rng"] } rustversion = "1.0.14" -parquet = { git = "https://github.com/apache/arrow-rs.git", rev = "c203785ca398b879960bffbd30b988c9728b7c23", default-features = false, features = [ +parquet = { git = "https://github.com/apache/arrow-rs.git", rev = "d17b2067d637c563eb315571e719807a6f482784", default-features = false, features = [ "arrow", ] } uuid = { version = "1.8.0", default-features = false } diff --git a/narrow-derive/src/enum.rs b/narrow-derive/src/enum.rs index 3521747f..3e485985 100644 --- a/narrow-derive/src/enum.rs +++ b/narrow-derive/src/enum.rs @@ -746,19 +746,12 @@ impl<'a> Enum<'a> { let (impl_generics, _, where_clause) = generics.split_for_impl(); let (_, ty_generics, _) = generics.split_for_impl(); let idx = self.variant_indices(); - let variant_idx = (0..self.variants.len()).map(|idx| idx.to_string()); let tokens = quote! { - impl #impl_generics ::std::convert::From<#ident #ty_generics> for ::std::vec::Vec<(::arrow_schema::Field, ::std::sync::Arc)> #where_clause { + impl #impl_generics ::std::convert::From<#ident #ty_generics> for ::std::vec::Vec<::std::sync::Arc> #where_clause { fn from(value: #ident #ty_generics) -> Self { vec![ #( - ( - << - <#self_ident as #narrow::array::union::EnumVariant<#idx>>::Data as #narrow::array::ArrayType - <<#self_ident #self_ty_generics as #narrow::array::union::EnumVariant<#idx>>::Data>>::Array as #narrow::arrow::Array - >::as_field(#variant_idx), - value.#idx.into() - ), + value.#idx.into(), )* ] } diff --git a/src/arrow/array/union.rs b/src/arrow/array/union.rs index 334f769c..803e1caa 100644 --- a/src/arrow/array/union.rs +++ b/src/arrow/array/union.rs @@ -78,22 +78,23 @@ impl< where for<'a> i8: From<&'a T>, >::Array: - UnionArrayTypeFields + Into)>>, + UnionArrayTypeFields + Into>>, arrow_buffer::ScalarBuffer: From>, + UnionArray: crate::arrow::Array, { fn from(value: UnionArray) -> Self { + let union_fields = match < UnionArray as crate::arrow::Array>::as_field("").data_type() { + DataType::Union(fields, _mode) => fields, + _ => unreachable!(), + }.to_owned(); // Safety: // - todo unsafe { arrow_array::UnionArray::new_unchecked( - &<>::Array< - Buffer, - OffsetItem, - SparseLayout, - > as UnionArrayTypeFields>::type_ids(), - arrow_buffer::ScalarBuffer::from(value.0.types).into_inner(), + union_fields, + arrow_buffer::ScalarBuffer::from(value.0.types), None, - value.0.variants.into() + value.0.variants.into(), ) } } @@ -108,23 +109,24 @@ impl< where for<'a> i8: From<&'a T>, >::Array: - UnionArrayTypeFields + Into)>>, + UnionArrayTypeFields + Into>>, arrow_buffer::ScalarBuffer: From>, arrow_buffer::ScalarBuffer: From>, + UnionArray: crate::arrow::Array, { fn from(value: UnionArray) -> Self { + let union_fields = match < UnionArray as crate::arrow::Array>::as_field("").data_type() { + DataType::Union(fields, _mode) => fields, + _ => unreachable!(), + }.to_owned(); // Safety: // - todo unsafe { arrow_array::UnionArray::new_unchecked( - &<>::Array< - Buffer, - OffsetItem, - DenseLayout, - > as UnionArrayTypeFields>::type_ids(), - arrow_buffer::ScalarBuffer::from(value.0.types).into_inner(), - Some(arrow_buffer::ScalarBuffer::::from(value.0.offsets).into_inner()), - value.0.variants.into() + union_fields, + arrow_buffer::ScalarBuffer::from(value.0.types), + Some(arrow_buffer::ScalarBuffer::::from(value.0.offsets)), + value.0.variants.into(), ) } } @@ -143,12 +145,12 @@ where FromIterator>, { fn from(value: arrow_array::UnionArray) -> Self { - let (types, offsets_opt, _field_type_ids, variants) = value.into_parts(); + let (_union_fields, type_ids, offsets_opt, variants) = value.into_parts(); match offsets_opt { Some(_) => panic!("expected array without offsets"), None => Self(SparseUnionArray { - variants: variants.into_iter().map(|(_, array)| array).collect(), - types: types.into(), + variants: variants.into_iter().collect(), + types: type_ids.into(), }), } } @@ -168,13 +170,13 @@ where FromIterator>, { fn from(value: arrow_array::UnionArray) -> Self { - let (types, offsets_opt, _field_types_ids, variants) = value.into_parts(); + let (_union_fields, type_ids, offsets_opt, variants) = value.into_parts(); match offsets_opt { None => panic!("expected array with offsets"), Some(offsets) => Self(DenseUnionArray { - variants: variants.into_iter().map(|(_, array)| array).collect(), + variants: variants.into_iter().collect(), offsets: offsets.into(), - types: types.into(), + types: type_ids.into(), }), } }