Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use vortex_array::vtable::ArrayId;
use vortex_error::VortexResult;
use vortex_error::vortex_err;

use super::ArrayFixture;
use crate::fixtures::ArrayFixture;

/// First partition of ClickBench hits, limited to 1000 rows.
const CLICKBENCH_URL: &str =
Expand Down
16 changes: 16 additions & 0 deletions vortex-test/compat-gen/src/fixtures/arrays/datasets/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

mod clickbench;
#[allow(clippy::cast_possible_truncation)]
mod tpch;

use crate::fixtures::ArrayFixture;

/// All dataset-derived fixtures.
pub fn fixtures() -> Vec<Box<dyn ArrayFixture>> {
let mut fixtures = Vec::new();
fixtures.extend(tpch::fixtures());
fixtures.extend(clickbench::fixtures());
fixtures
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use vortex_array::arrow::FromArrowArray;
use vortex_array::vtable::ArrayId;
use vortex_error::VortexResult;

use super::ArrayFixture;
use crate::fixtures::ArrayFixture;

const SCALE_FACTOR: f64 = 0.01;

Expand Down
15 changes: 15 additions & 0 deletions vortex-test/compat-gen/src/fixtures/arrays/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

mod datasets;
mod synthetic;

use super::ArrayFixture;

/// All array fixtures.
pub fn fixtures() -> Vec<Box<dyn ArrayFixture>> {
let mut fixtures = Vec::new();
fixtures.extend(synthetic::fixtures());
fixtures.extend(datasets::fixtures());
fixtures
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use vortex_array::ArrayRef;
use vortex_array::IntoArray;
use vortex_array::arrays::Bool;
use vortex_array::arrays::BoolArray;
use vortex_array::arrays::StructArray;
use vortex_array::dtype::FieldNames;
use vortex_array::validity::Validity;
use vortex_array::vtable::ArrayId;
use vortex_error::VortexResult;

use crate::fixtures::ArrayFixture;

pub struct BooleansFixture;

impl ArrayFixture for BooleansFixture {
fn name(&self) -> &str {
"booleans.vortex"
}

fn description(&self) -> &str {
"Boolean arrays with mixed true/false values including a nullable column"
}

fn expected_encodings(&self) -> Vec<ArrayId> {
vec![Bool::ID]
}

fn build(&self) -> VortexResult<ArrayRef> {
let bools = BoolArray::from_iter([true, false, true, true, false]);
let nullable_bools =
BoolArray::from_iter([Some(true), None, Some(false), None, Some(true)]);
let arr = StructArray::try_new(
FieldNames::from(["flag", "nullable_flag"]),
vec![bools.into_array(), nullable_bools.into_array()],
5,
Validity::NonNullable,
)?;
Ok(arr.into_array())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use vortex_array::ArrayRef;
use vortex_array::IntoArray;
use vortex_array::arrays::ChunkedArray;
use vortex_array::arrays::Primitive;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::arrays::StructArray;
use vortex_array::dtype::FieldNames;
use vortex_array::validity::Validity;
use vortex_array::vtable::ArrayId;
use vortex_error::VortexResult;

use crate::fixtures::ArrayFixture;

pub struct ChunkedFixture;

impl ArrayFixture for ChunkedFixture {
fn name(&self) -> &str {
"chunked.vortex"
}

fn description(&self) -> &str {
"ChunkedArray with 3 chunks of 1000 rows each containing deterministic u32 values"
}

fn expected_encodings(&self) -> Vec<ArrayId> {
vec![Primitive::ID]
}

fn build(&self) -> VortexResult<ArrayRef> {
let value_gen = |chunk_idx| {
let values: Vec<u32> = (0u32..1000).map(|i| chunk_idx * 1000 + i).collect();
let primitives =
PrimitiveArray::new(vortex_buffer::Buffer::from(values), Validity::NonNullable);
Ok(StructArray::try_new(
FieldNames::from(["id"]),
vec![primitives.into_array()],
1000,
Validity::NonNullable,
)?
.into_array())
};

Ok(
ChunkedArray::from_iter((0u32..3).map(value_gen).collect::<VortexResult<Vec<_>>>()?)
.into_array(),
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use vortex_array::ArrayRef;
use vortex_array::IntoArray;
use vortex_array::arrays::FixedSizeList;
use vortex_array::arrays::FixedSizeListArray;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::arrays::StructArray;
use vortex_array::dtype::FieldNames;
use vortex_array::validity::Validity;
use vortex_array::vtable::ArrayId;
use vortex_buffer::buffer;
use vortex_error::VortexResult;

use crate::fixtures::ArrayFixture;

pub struct FixedSizeListFixture;

impl ArrayFixture for FixedSizeListFixture {
fn name(&self) -> &str {
"fixed_size_list.vortex"
}

fn description(&self) -> &str {
"Fixed-size list arrays (e.g. 3-element vectors)"
}

fn expected_encodings(&self) -> Vec<ArrayId> {
vec![FixedSizeList::ID]
}

fn build(&self) -> VortexResult<ArrayRef> {
// 4 vectors of 3 f64 each
let elements = PrimitiveArray::new(
buffer![
1.0f64, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0
],
Validity::NonNullable,
);
let fsl = FixedSizeListArray::try_new(elements.into_array(), 3, Validity::NonNullable, 4)?;

let arr = StructArray::try_new(
FieldNames::from(["vectors"]),
vec![fsl.into_array()],
4,
Validity::NonNullable,
)?;
Ok(arr.into_array())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use vortex_array::ArrayRef;
use vortex_array::IntoArray;
use vortex_array::arrays::List;
use vortex_array::arrays::ListArray;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::arrays::StructArray;
use vortex_array::arrays::VarBinArray;
use vortex_array::dtype::FieldNames;
use vortex_array::validity::Validity;
use vortex_array::vtable::ArrayId;
use vortex_buffer::buffer;
use vortex_error::VortexResult;

use crate::fixtures::ArrayFixture;

pub struct ListFixture;

impl ArrayFixture for ListFixture {
fn name(&self) -> &str {
"list.vortex"
}

fn description(&self) -> &str {
"Variable-length list arrays with integer and string elements"
}

fn expected_encodings(&self) -> Vec<ArrayId> {
vec![List::ID]
}

fn build(&self) -> VortexResult<ArrayRef> {
// List of i32: [[1,2,3], [4,5], [6], [7,8,9,10]]
let elements = PrimitiveArray::new(
buffer![1i32, 2, 3, 4, 5, 6, 7, 8, 9, 10],
Validity::NonNullable,
);
let offsets = PrimitiveArray::new(buffer![0i64, 3, 5, 6, 10], Validity::NonNullable);
let int_list = ListArray::try_new(
elements.into_array(),
offsets.into_array(),
Validity::NonNullable,
)?;

// List of strings: [["a","b"], ["hello"], [], ["x","y","z"]]
let str_elements = VarBinArray::from(vec!["a", "b", "hello", "x", "y", "z"]);
let str_offsets = PrimitiveArray::new(buffer![0i64, 2, 3, 3, 6], Validity::NonNullable);
let str_list = ListArray::try_new(
str_elements.into_array(),
str_offsets.into_array(),
Validity::NonNullable,
)?;

let arr = StructArray::try_new(
FieldNames::from(["int_list", "str_list"]),
vec![int_list.into_array(), str_list.into_array()],
4,
Validity::NonNullable,
)?;
Ok(arr.into_array())
}
}
33 changes: 33 additions & 0 deletions vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

//! Per-array-type synthetic fixtures.
//!
//! Each fixture exercises a core Vortex array type with boundary values and nullable variants.

mod bool;
mod chunked;
mod fixed_size_list;
mod list;
mod null;
mod primitive;
mod struct_nested;
mod varbin;
mod varbinview;

use crate::fixtures::ArrayFixture;

/// All per-array-type fixtures.
pub fn fixtures() -> Vec<Box<dyn ArrayFixture>> {
vec![
Box::new(primitive::PrimitivesFixture),
Box::new(varbin::VarBinFixture),
Box::new(varbinview::VarBinViewFixture),
Box::new(bool::BooleansFixture),
Box::new(struct_nested::StructNestedFixture),
Box::new(chunked::ChunkedFixture),
Box::new(list::ListFixture),
Box::new(fixed_size_list::FixedSizeListFixture),
Box::new(null::NullFixture),
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use vortex_array::ArrayRef;
use vortex_array::IntoArray;
use vortex_array::arrays::Null;
use vortex_array::arrays::NullArray;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::arrays::StructArray;
use vortex_array::dtype::FieldNames;
use vortex_array::validity::Validity;
use vortex_array::vtable::ArrayId;
use vortex_buffer::buffer;
use vortex_error::VortexResult;

use crate::fixtures::ArrayFixture;

pub struct NullFixture;

impl ArrayFixture for NullFixture {
fn name(&self) -> &str {
"null.vortex"
}

fn description(&self) -> &str {
"All-null column using NullArray alongside an integer column"
}

fn expected_encodings(&self) -> Vec<ArrayId> {
vec![Null::ID]
}

fn build(&self) -> VortexResult<ArrayRef> {
let null_col = NullArray::new(10);
let int_col = PrimitiveArray::new(
buffer![0i32, 1, 2, 3, 4, 5, 6, 7, 8, 9],
Validity::NonNullable,
);

let arr = StructArray::try_new(
FieldNames::from(["nulls", "ids"]),
vec![null_col.into_array(), int_col.into_array()],
10,
Validity::NonNullable,
)?;
Ok(arr.into_array())
}
}
Loading
Loading