Skip to content

Commit 74586e2

Browse files
committed
add array variant to scalar value
Signed-off-by: Connor Tsui <[email protected]>
1 parent cca6e9e commit 74586e2

58 files changed

Lines changed: 1593 additions & 1026 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎encodings/parquet-variant/src/operations.rs‎

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,7 @@ fn scalar_from_typed_value_scalar(
109109
) -> VortexResult<Scalar> {
110110
match typed_value.dtype() {
111111
DType::List(..) => {
112-
let list = typed_value.as_list();
113-
let children = list
114-
.elements()
115-
.unwrap_or_default()
116-
.into_iter()
117-
.map(|element| {
118-
let nested = scalar_from_shredded_field_scalar(metadata, element)?;
119-
Ok(Scalar::variant(nested))
120-
})
121-
.collect::<VortexResult<Vec<_>>>()?;
122-
Ok(Scalar::list(
123-
DType::Variant(Nullability::NonNullable),
124-
children,
125-
Nullability::NonNullable,
126-
))
112+
todo!()
127113
}
128114
DType::Struct(..) => scalar_from_shredded_object_scalar(metadata, value, typed_value),
129115
_ => Ok(typed_value),
@@ -207,7 +193,7 @@ fn scalar_from_shredded_object_scalar(
207193
let fields = StructFields::new(FieldNames::from(names), dtypes);
208194
Scalar::try_new(
209195
DType::Struct(fields, Nullability::NonNullable),
210-
Some(ScalarValue::List(field_values)),
196+
Some(ScalarValue::Struct(field_values)),
211197
)
212198
}
213199

@@ -303,11 +289,7 @@ fn parquet_variant_to_scalar(variant: PqVariant<'_, '_>) -> VortexResult<Scalar>
303289
// TODO: Should this depend on the new UUID-extension type? leaving this for now.
304290
PqVariant::Uuid(v) => Scalar::utf8(v.to_string(), nn),
305291
PqVariant::List(values) => {
306-
let children = values
307-
.iter()
308-
.map(|v| parquet_variant_to_scalar(v).map(Scalar::variant))
309-
.collect::<VortexResult<Vec<_>>>()?;
310-
Scalar::list(DType::Variant(nn), children, nn)
292+
todo!()
311293
}
312294
PqVariant::Object(values) => {
313295
let mut names = Vec::new();
@@ -323,7 +305,7 @@ fn parquet_variant_to_scalar(variant: PqVariant<'_, '_>) -> VortexResult<Scalar>
323305
let fields = StructFields::new(FieldNames::from(names), dtypes);
324306
Scalar::try_new(
325307
DType::Struct(fields, nn),
326-
Some(ScalarValue::List(field_values)),
308+
Some(ScalarValue::Struct(field_values)),
327309
)?
328310
}
329311
})

‎encodings/sequence/src/compute/list_contains.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ mod tests {
6767

6868
#[test]
6969
fn test_list_contains_seq() {
70-
let list_scalar = Scalar::list(
70+
let list_scalar = Scalar::list_from_scalars(
7171
Arc::new(I32.into()),
7272
vec![1.into(), 3.into()],
7373
Nullability::Nullable,

‎encodings/sparse/src/canonical.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ mod test {
12441244
.into_array();
12451245

12461246
let indices = buffer![0u8, 2u8, 4u8].into_array();
1247-
let fill_value = Scalar::fixed_size_list(
1247+
let fill_value = Scalar::fixed_size_list_from_scalars(
12481248
Arc::new(DType::Primitive(PType::I32, NonNullable)),
12491249
vec![
12501250
Scalar::primitive(99i32, NonNullable),
@@ -1282,7 +1282,7 @@ mod test {
12821282
.into_array();
12831283

12841284
let indices = buffer![1u16, 3u16, 4u16].into_array();
1285-
let fill_value = Scalar::fixed_size_list(
1285+
let fill_value = Scalar::fixed_size_list_from_scalars(
12861286
Arc::new(DType::Primitive(PType::I32, NonNullable)),
12871287
vec![
12881288
Scalar::primitive(7i32, NonNullable),
@@ -1329,7 +1329,7 @@ mod test {
13291329
let indices = buffer![5u32, 50, 95].into_array();
13301330

13311331
// Fill value [99, 99] will appear 97 times but stored only once.
1332-
let fill_value = Scalar::fixed_size_list(
1332+
let fill_value = Scalar::fixed_size_list_from_scalars(
13331333
Arc::new(DType::Primitive(PType::I32, NonNullable)),
13341334
vec![
13351335
Scalar::primitive(99i32, NonNullable),
@@ -1387,7 +1387,7 @@ mod test {
13871387
.into_array();
13881388

13891389
let indices = buffer![0u32].into_array();
1390-
let fill_value = Scalar::fixed_size_list(
1390+
let fill_value = Scalar::fixed_size_list_from_scalars(
13911391
Arc::new(DType::Primitive(PType::I32, NonNullable)),
13921392
vec![
13931393
Scalar::primitive(1i32, NonNullable),

‎fuzz/src/array/scalar_at.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub fn scalar_at_canonical_array(canonical: Canonical, index: usize) -> VortexRe
6060
.vortex_expect("scalar_at_canonical_array should succeed in fuzz test")
6161
})
6262
.collect();
63-
Scalar::list(
63+
Scalar::list_from_scalars(
6464
Arc::new(list.dtype().clone()),
6565
children,
6666
array.dtype().nullability(),
@@ -78,7 +78,11 @@ pub fn scalar_at_canonical_array(canonical: Canonical, index: usize) -> VortexRe
7878
.vortex_expect("scalar_at_canonical_array should succeed in fuzz test")
7979
})
8080
.collect();
81-
Scalar::fixed_size_list(list.dtype().clone(), children, array.dtype().nullability())
81+
Scalar::fixed_size_list_from_scalars(
82+
list.dtype().clone(),
83+
children,
84+
array.dtype().nullability(),
85+
)
8286
}
8387
Canonical::Struct(array) => {
8488
let field_scalars: Vec<Scalar> = array

‎vortex-array/public-api.lock‎

Lines changed: 126 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8216,6 +8216,8 @@ pub fn vortex_array::builders::PrimitiveBuilder<T>::set_validity(&mut self, vali
82168216

82178217
pub unsafe fn vortex_array::builders::PrimitiveBuilder<T>::set_validity_unchecked(&mut self, validity: vortex_mask::Mask)
82188218

8219+
pub fn vortex_array::builders::build_array_from_scalars(dtype: &vortex_array::dtype::DType, scalars: &[vortex_array::scalar::Scalar]) -> vortex_array::ArrayRef
8220+
82198221
pub fn vortex_array::builders::builder_with_capacity(dtype: &vortex_array::dtype::DType, capacity: usize) -> alloc::boxed::Box<dyn vortex_array::builders::ArrayBuilder>
82208222

82218223
pub mod vortex_array::builtins
@@ -13792,16 +13794,18 @@ pub fn vortex_array::variants::PrimitiveTyped<'_>::index_lt(&self, idx: usize, e
1379213794

1379313795
pub enum vortex_array::scalar::ScalarValue
1379413796

13797+
pub vortex_array::scalar::ScalarValue::Array(vortex_array::ArrayRef)
13798+
1379513799
pub vortex_array::scalar::ScalarValue::Binary(vortex_buffer::ByteBuffer)
1379613800

1379713801
pub vortex_array::scalar::ScalarValue::Bool(bool)
1379813802

1379913803
pub vortex_array::scalar::ScalarValue::Decimal(vortex_array::scalar::DecimalValue)
1380013804

13801-
pub vortex_array::scalar::ScalarValue::List(alloc::vec::Vec<core::option::Option<vortex_array::scalar::ScalarValue>>)
13802-
1380313805
pub vortex_array::scalar::ScalarValue::Primitive(vortex_array::scalar::PValue)
1380413806

13807+
pub vortex_array::scalar::ScalarValue::Struct(alloc::vec::Vec<core::option::Option<vortex_array::scalar::ScalarValue>>)
13808+
1380513809
pub vortex_array::scalar::ScalarValue::Utf8(vortex_buffer::string::BufferString)
1380613810

1380713811
pub vortex_array::scalar::ScalarValue::Variant(alloc::boxed::Box<vortex_array::scalar::Scalar>)
@@ -13814,10 +13818,12 @@ pub fn vortex_array::scalar::ScalarValue::as_bool(&self) -> bool
1381413818

1381513819
pub fn vortex_array::scalar::ScalarValue::as_decimal(&self) -> &vortex_array::scalar::DecimalValue
1381613820

13817-
pub fn vortex_array::scalar::ScalarValue::as_list(&self) -> &[core::option::Option<vortex_array::scalar::ScalarValue>]
13821+
pub fn vortex_array::scalar::ScalarValue::as_list(&self) -> &vortex_array::ArrayRef
1381813822

1381913823
pub fn vortex_array::scalar::ScalarValue::as_primitive(&self) -> &vortex_array::scalar::PValue
1382013824

13825+
pub fn vortex_array::scalar::ScalarValue::as_struct_fields(&self) -> &[core::option::Option<vortex_array::scalar::ScalarValue>]
13826+
1382113827
pub fn vortex_array::scalar::ScalarValue::as_utf8(&self) -> &vortex_buffer::string::BufferString
1382213828

1382313829
pub fn vortex_array::scalar::ScalarValue::as_variant(&self) -> &vortex_array::scalar::Scalar
@@ -13828,10 +13834,12 @@ pub fn vortex_array::scalar::ScalarValue::into_bool(self) -> bool
1382813834

1382913835
pub fn vortex_array::scalar::ScalarValue::into_decimal(self) -> vortex_array::scalar::DecimalValue
1383013836

13831-
pub fn vortex_array::scalar::ScalarValue::into_list(self) -> alloc::vec::Vec<core::option::Option<vortex_array::scalar::ScalarValue>>
13837+
pub fn vortex_array::scalar::ScalarValue::into_list(self) -> vortex_array::ArrayRef
1383213838

1383313839
pub fn vortex_array::scalar::ScalarValue::into_primitive(self) -> vortex_array::scalar::PValue
1383413840

13841+
pub fn vortex_array::scalar::ScalarValue::into_struct_fields(self) -> alloc::vec::Vec<core::option::Option<vortex_array::scalar::ScalarValue>>
13842+
1383513843
pub fn vortex_array::scalar::ScalarValue::into_utf8(self) -> vortex_buffer::string::BufferString
1383613844

1383713845
pub fn vortex_array::scalar::ScalarValue::into_variant(self) -> vortex_array::scalar::Scalar
@@ -13856,7 +13864,7 @@ impl core::cmp::Eq for vortex_array::scalar::ScalarValue
1385613864

1385713865
impl core::cmp::PartialEq for vortex_array::scalar::ScalarValue
1385813866

13859-
pub fn vortex_array::scalar::ScalarValue::eq(&self, other: &vortex_array::scalar::ScalarValue) -> bool
13867+
pub fn vortex_array::scalar::ScalarValue::eq(&self, other: &Self) -> bool
1386013868

1386113869
impl core::cmp::PartialOrd for vortex_array::scalar::ScalarValue
1386213870

@@ -14028,9 +14036,7 @@ pub fn vortex_array::scalar::ScalarValue::fmt(&self, f: &mut core::fmt::Formatte
1402814036

1402914037
impl core::hash::Hash for vortex_array::scalar::ScalarValue
1403014038

14031-
pub fn vortex_array::scalar::ScalarValue::hash<__H: core::hash::Hasher>(&self, state: &mut __H)
14032-
14033-
impl core::marker::StructuralPartialEq for vortex_array::scalar::ScalarValue
14039+
pub fn vortex_array::scalar::ScalarValue::hash<H: core::hash::Hasher>(&self, state: &mut H)
1403414040

1403514041
impl<T> core::convert::From<alloc::vec::Vec<T>> for vortex_array::scalar::ScalarValue where T: vortex_array::dtype::NativeDType, vortex_array::scalar::Scalar: core::convert::From<T>
1403614042

@@ -14306,6 +14312,8 @@ pub struct vortex_array::scalar::ListScalar<'a>
1430614312

1430714313
impl<'a> vortex_array::scalar::ListScalar<'a>
1430814314

14315+
pub fn vortex_array::scalar::ListScalar<'a>::as_array(&self) -> core::option::Option<&'a vortex_array::ArrayRef>
14316+
1430914317
pub fn vortex_array::scalar::ListScalar<'a>::dtype(&self) -> &'a vortex_array::dtype::DType
1431014318

1431114319
pub fn vortex_array::scalar::ListScalar<'a>::element(&self, idx: usize) -> core::option::Option<vortex_array::scalar::Scalar>
@@ -14526,12 +14534,14 @@ pub fn vortex_array::scalar::Scalar::extension<V: vortex_array::dtype::extension
1452614534

1452714535
pub fn vortex_array::scalar::Scalar::extension_ref(ext_dtype: vortex_array::dtype::extension::ExtDTypeRef, storage_scalar: vortex_array::scalar::Scalar) -> Self
1452814536

14529-
pub fn vortex_array::scalar::Scalar::fixed_size_list(element_dtype: impl core::convert::Into<alloc::sync::Arc<vortex_array::dtype::DType>>, children: alloc::vec::Vec<vortex_array::scalar::Scalar>, nullability: vortex_array::dtype::Nullability) -> Self
14537+
pub fn vortex_array::scalar::Scalar::fixed_size_list_from_scalars(element_dtype: impl core::convert::Into<alloc::sync::Arc<vortex_array::dtype::DType>>, children: alloc::vec::Vec<vortex_array::scalar::Scalar>, nullability: vortex_array::dtype::Nullability) -> Self
1453014538

14531-
pub fn vortex_array::scalar::Scalar::list(element_dtype: impl core::convert::Into<alloc::sync::Arc<vortex_array::dtype::DType>>, children: alloc::vec::Vec<vortex_array::scalar::Scalar>, nullability: vortex_array::dtype::Nullability) -> Self
14539+
pub fn vortex_array::scalar::Scalar::list_array(parent_dtype: vortex_array::dtype::DType, elem_list: vortex_array::ArrayRef) -> Self
1453214540

1453314541
pub fn vortex_array::scalar::Scalar::list_empty(element_dtype: alloc::sync::Arc<vortex_array::dtype::DType>, nullability: vortex_array::dtype::Nullability) -> Self
1453414542

14543+
pub fn vortex_array::scalar::Scalar::list_from_scalars(element_dtype: impl core::convert::Into<alloc::sync::Arc<vortex_array::dtype::DType>>, children: alloc::vec::Vec<vortex_array::scalar::Scalar>, nullability: vortex_array::dtype::Nullability) -> Self
14544+
1453514545
pub fn vortex_array::scalar::Scalar::primitive<T: vortex_array::dtype::NativePType + core::convert::Into<vortex_array::scalar::PValue>>(value: T, nullability: vortex_array::dtype::Nullability) -> Self
1453614546

1453714547
pub fn vortex_array::scalar::Scalar::primitive_value(value: vortex_array::scalar::PValue, ptype: vortex_array::dtype::PType, nullability: vortex_array::dtype::Nullability) -> Self
@@ -18264,6 +18274,112 @@ pub fn vortex_array::serde::ArrayNodeFlatBuffer<'a>::try_new(ctx: &'a vortex_arr
1826418274

1826518275
pub fn vortex_array::serde::ArrayNodeFlatBuffer<'a>::try_write_flatbuffer<'fb>(&self, fbb: &mut flatbuffers::builder::FlatBufferBuilder<'fb>) -> vortex_error::VortexResult<flatbuffers::primitives::WIPOffset<vortex_flatbuffers::array::ArrayNode<'fb>>>
1826618276

18277+
<<<<<<< HEAD
18278+
||||||| parent of 22d6a6a4d (add array variant to scalar value)
18279+
pub struct vortex_array::serde::ArrayParts
18280+
18281+
impl vortex_array::serde::ArrayParts
18282+
18283+
pub fn vortex_array::serde::ArrayParts::buffer(&self, idx: usize) -> vortex_error::VortexResult<vortex_array::buffer::BufferHandle>
18284+
18285+
pub fn vortex_array::serde::ArrayParts::buffer_lengths(&self) -> alloc::vec::Vec<usize>
18286+
18287+
pub fn vortex_array::serde::ArrayParts::child(&self, idx: usize) -> vortex_array::serde::ArrayParts
18288+
18289+
pub fn vortex_array::serde::ArrayParts::decode(&self, dtype: &vortex_array::dtype::DType, len: usize, ctx: &vortex_array::ArrayContext, session: &vortex_session::VortexSession) -> vortex_error::VortexResult<vortex_array::ArrayRef>
18290+
18291+
pub fn vortex_array::serde::ArrayParts::encoding_id(&self) -> u16
18292+
18293+
pub fn vortex_array::serde::ArrayParts::from_array_tree(array_tree: impl core::convert::Into<vortex_buffer::ByteBuffer>) -> vortex_error::VortexResult<Self>
18294+
18295+
pub fn vortex_array::serde::ArrayParts::from_flatbuffer_and_segment(array_tree: vortex_buffer::ByteBuffer, segment: vortex_array::buffer::BufferHandle) -> vortex_error::VortexResult<Self>
18296+
18297+
pub fn vortex_array::serde::ArrayParts::from_flatbuffer_and_segment_with_overrides(array_tree: vortex_buffer::ByteBuffer, segment: vortex_array::buffer::BufferHandle, buffer_overrides: &vortex_utils::aliases::hash_map::HashMap<u32, vortex_buffer::ByteBuffer>) -> vortex_error::VortexResult<Self>
18298+
18299+
pub fn vortex_array::serde::ArrayParts::from_flatbuffer_with_buffers(array_tree: impl core::convert::Into<vortex_buffer::ByteBuffer>, buffers: alloc::vec::Vec<vortex_array::buffer::BufferHandle>) -> vortex_error::VortexResult<Self>
18300+
18301+
pub fn vortex_array::serde::ArrayParts::metadata(&self) -> &[u8]
18302+
18303+
pub fn vortex_array::serde::ArrayParts::nbuffers(&self) -> usize
18304+
18305+
pub fn vortex_array::serde::ArrayParts::nchildren(&self) -> usize
18306+
18307+
impl core::clone::Clone for vortex_array::serde::ArrayParts
18308+
18309+
pub fn vortex_array::serde::ArrayParts::clone(&self) -> vortex_array::serde::ArrayParts
18310+
18311+
impl core::convert::TryFrom<vortex_array::buffer::BufferHandle> for vortex_array::serde::ArrayParts
18312+
18313+
pub type vortex_array::serde::ArrayParts::Error = vortex_error::VortexError
18314+
18315+
pub fn vortex_array::serde::ArrayParts::try_from(value: vortex_array::buffer::BufferHandle) -> core::result::Result<Self, Self::Error>
18316+
18317+
impl core::convert::TryFrom<vortex_buffer::buffer::Buffer<u8>> for vortex_array::serde::ArrayParts
18318+
18319+
pub type vortex_array::serde::ArrayParts::Error = vortex_error::VortexError
18320+
18321+
pub fn vortex_array::serde::ArrayParts::try_from(value: vortex_buffer::ByteBuffer) -> core::result::Result<Self, Self::Error>
18322+
18323+
impl core::fmt::Debug for vortex_array::serde::ArrayParts
18324+
18325+
pub fn vortex_array::serde::ArrayParts::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
18326+
18327+
=======
18328+
pub struct vortex_array::serde::ArrayParts
18329+
18330+
impl vortex_array::serde::ArrayParts
18331+
18332+
pub fn vortex_array::serde::ArrayParts::buffer(&self, idx: usize) -> vortex_error::VortexResult<vortex_array::buffer::BufferHandle>
18333+
18334+
pub fn vortex_array::serde::ArrayParts::buffer_lengths(&self) -> alloc::vec::Vec<usize>
18335+
18336+
pub fn vortex_array::serde::ArrayParts::child(&self, idx: usize) -> vortex_array::serde::ArrayParts
18337+
18338+
pub fn vortex_array::serde::ArrayParts::decode(&self, dtype: &vortex_array::dtype::DType, len: usize, ctx: &vortex_array::ArrayContext, session: &vortex_session::VortexSession) -> vortex_error::VortexResult<vortex_array::ArrayRef>
18339+
18340+
pub fn vortex_array::serde::ArrayParts::encoding_id(&self) -> u16
18341+
18342+
pub fn vortex_array::serde::ArrayParts::from_array_tree(array_tree: impl core::convert::Into<vortex_buffer::ByteBuffer>) -> vortex_error::VortexResult<Self>
18343+
18344+
pub fn vortex_array::serde::ArrayParts::from_flatbuffer_and_segment(array_tree: vortex_buffer::ByteBuffer, segment: vortex_array::buffer::BufferHandle) -> vortex_error::VortexResult<Self>
18345+
18346+
pub fn vortex_array::serde::ArrayParts::from_flatbuffer_and_segment_with_overrides(array_tree: vortex_buffer::ByteBuffer, segment: vortex_array::buffer::BufferHandle, buffer_overrides: &vortex_utils::aliases::hash_map::HashMap<u32, vortex_buffer::ByteBuffer>) -> vortex_error::VortexResult<Self>
18347+
18348+
pub fn vortex_array::serde::ArrayParts::from_flatbuffer_with_buffers(array_tree: impl core::convert::Into<vortex_buffer::ByteBuffer>, buffers: alloc::vec::Vec<vortex_array::buffer::BufferHandle>) -> vortex_error::VortexResult<Self>
18349+
18350+
pub fn vortex_array::serde::ArrayParts::metadata(&self) -> &[u8]
18351+
18352+
pub fn vortex_array::serde::ArrayParts::nbuffers(&self) -> usize
18353+
18354+
pub fn vortex_array::serde::ArrayParts::nchildren(&self) -> usize
18355+
18356+
impl core::clone::Clone for vortex_array::serde::ArrayParts
18357+
18358+
pub fn vortex_array::serde::ArrayParts::clone(&self) -> vortex_array::serde::ArrayParts
18359+
18360+
impl core::convert::TryFrom<&[u8]> for vortex_array::serde::ArrayParts
18361+
18362+
pub type vortex_array::serde::ArrayParts::Error = vortex_error::VortexError
18363+
18364+
pub fn vortex_array::serde::ArrayParts::try_from(value: &[u8]) -> core::result::Result<Self, Self::Error>
18365+
18366+
impl core::convert::TryFrom<vortex_array::buffer::BufferHandle> for vortex_array::serde::ArrayParts
18367+
18368+
pub type vortex_array::serde::ArrayParts::Error = vortex_error::VortexError
18369+
18370+
pub fn vortex_array::serde::ArrayParts::try_from(value: vortex_array::buffer::BufferHandle) -> core::result::Result<Self, Self::Error>
18371+
18372+
impl core::convert::TryFrom<vortex_buffer::buffer::Buffer<u8>> for vortex_array::serde::ArrayParts
18373+
18374+
pub type vortex_array::serde::ArrayParts::Error = vortex_error::VortexError
18375+
18376+
pub fn vortex_array::serde::ArrayParts::try_from(value: vortex_buffer::ByteBuffer) -> core::result::Result<Self, Self::Error>
18377+
18378+
impl core::fmt::Debug for vortex_array::serde::ArrayParts
18379+
18380+
pub fn vortex_array::serde::ArrayParts::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
18381+
18382+
>>>>>>> 22d6a6a4d (add array variant to scalar value)
1826718383
pub struct vortex_array::serde::SerializeOptions
1826818384

1826918385
pub vortex_array::serde::SerializeOptions::include_padding: bool

‎vortex-array/src/arrays/arbitrary.rs‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ use crate::builders::ArrayBuilder;
2626
use crate::builders::DecimalBuilder;
2727
use crate::builders::FixedSizeListBuilder;
2828
use crate::builders::ListViewBuilder;
29+
use crate::builders::build_array_from_scalars;
2930
use crate::dtype::DType;
3031
use crate::dtype::IntegerPType;
3132
use crate::dtype::NativePType;
3233
use crate::dtype::Nullability;
3334
use crate::dtype::PType;
3435
use crate::match_each_decimal_value_type;
3536
use crate::scalar::Scalar;
37+
use crate::scalar::ScalarValue;
3638
use crate::scalar::arbitrary::random_scalar;
3739
use crate::validity::Validity;
3840

@@ -250,12 +252,18 @@ fn random_list_scalar(
250252
u: &mut Unstructured,
251253
elem_dtype: &Arc<DType>,
252254
list_size: u32,
253-
null: Nullability,
255+
nullability: Nullability,
254256
) -> Result<Scalar> {
255257
let elems = (0..list_size)
256258
.map(|_| random_scalar(u, elem_dtype))
257259
.collect::<Result<Vec<_>>>()?;
258-
Ok(Scalar::list(elem_dtype.clone(), elems, null))
260+
let array = build_array_from_scalars(elem_dtype, &elems);
261+
262+
Scalar::try_new(
263+
DType::List(elem_dtype.clone(), nullability),
264+
Some(ScalarValue::Array(array)),
265+
)
266+
.map_err(|_| arbitrary::Error::IncorrectFormat)
259267
}
260268

261269
fn random_string(

0 commit comments

Comments
 (0)