Skip to content
Open
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
12 changes: 0 additions & 12 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
[profile.default]
slow-timeout = { period = "30s", terminate-after = 5 }

# Spatial tests concurrently call INSTALL spatial which fails
[test-groups]
duckdb-extension-install = { max-threads = 1 }

[[profile.default.overrides]]
filter = 'test(compress_large_int | fsst_compress_offsets_overflow_i32)'
priority = 100

[[profile.default.overrides]]
filter = 'package(vortex-duckdb) & (test(spatial_) | test(test_geometry))'
test-group = 'duckdb-extension-install'
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion encodings/fsst/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ divan = { workspace = true }
mimalloc = { workspace = true }
rand = { workspace = true }
rstest = { workspace = true }
test-with = { workspace = true }
vortex-array = { workspace = true, features = ["_test-harness"] }
vortex-expr = { workspace = true }

Expand Down
56 changes: 0 additions & 56 deletions encodings/fsst/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,59 +201,3 @@ fn fsst_compress_offset_width_rollover() -> VortexResult<()> {

Ok(())
}

// TODO(someone): ideally CI would run this in release mode as well since debug builds make the
// allocation and compression loop substantially slower.
/// Regression for #7833: [`fsst_compress`] must accept inputs whose cumulative compressed
/// bytes exceed [`i32::MAX`]. Before the fix, the compress path hardcoded
/// [`VarBinBuilder<i32>`] for the FSST output and panicked in
/// [`VarBinBuilder::append_value`] once cumulative compressed bytes crossed the boundary.
///
/// The compressor is built with an empty symbol table, so every input byte misses the table
/// and is escape-coded at exactly two output bytes per input byte. This makes the output
/// size deterministic and crosses the i32 boundary with roughly half the input bytes that
/// an incompressible-input construction would need. The input is built with
/// [`VarBinBuilder<i64>`] so the input itself does not panic, which confirms the overflow
/// is on the FSST output side. After the fix the test must succeed with the row count
/// preserved.
///
/// Allocates ~1.1 GiB for the input and ~2.1 GiB for the FSST output (~3.2 GiB total), so
/// it is gated to CI runs and skipped when `VORTEX_SKIP_SLOW_TESTS` is set. To run it
/// locally:
///
/// ```text
/// CI=1 cargo test --release -p vortex-fsst fsst_compress_offsets
/// ```
///
/// [`fsst_compress`]: crate::compress::fsst_compress
#[test_with::env(CI)]
#[test_with::no_env(VORTEX_SKIP_SLOW_TESTS)]
fn fsst_compress_offsets_overflow_i32() {
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Resolved
const STRING_LEN: usize = 64 * 1024;
// Escape coding doubles every byte, so ~1.06 GiB of input compresses to ~2.13 GiB,
// comfortably past i32::MAX.
const TOTAL_BYTES: usize = (1usize << 30) + (64 << 20);
const N: usize = TOTAL_BYTES / STRING_LEN;

println!("building large VarBinArray");
let string = vec![b'a'; STRING_LEN];
let mut builder = VarBinBuilder::<i64>::with_capacity_in(
DType::Utf8(Nullability::NonNullable),
N,
BufferAllocatorRef::static_ref(),
);
for _ in 0..N {
builder.append_value(&string);
}
let array = builder.finish_into_varbin().into_array();

let compressor = CompressorBuilder::default().build();
let len = array.len();
let mut ctx = SESSION.create_execution_ctx();

println!("compressing to FSST");
let compressed = fsst_compress(&array, &compressor, &mut ctx).unwrap();
assert_eq!(compressed.len(), len);
// Prove the regression condition was exercised: compressed bytes crossed i32::MAX.
assert!(compressed.codes_bytes().len() > i32::MAX as usize);
}
21 changes: 10 additions & 11 deletions encodings/uuid/src/arrow_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

mod tests {
use std::sync::Arc;
use std::sync::LazyLock;

use arrow_array::builder::FixedSizeBinaryBuilder;
use arrow_schema::DataType;
Expand Down Expand Up @@ -45,6 +46,12 @@ mod tests {
use crate::Uuid;
use crate::UuidMetadata;

static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = VortexSession::empty();
crate::initialize(&session);
session
});

struct UuidCase {
array: ArrayRef,
field: Field,
Expand All @@ -71,11 +78,7 @@ mod tests {
Some(Version::Custom),
Some(Version::Max),
]));
let mut bytes = tc.draw(
gs::vecs(gs::integers::<u8>())
.min_size(len * 16)
.max_size(len * 16),
);
let mut bytes = tc.draw(gs::binary().min_size(len * 16).max_size(len * 16));

if let Some(version) = version {
set_uuid_version(&mut bytes, version);
Expand Down Expand Up @@ -133,9 +136,7 @@ mod tests {

#[track_caller]
fn check_uuid_round_trip(tc: &TestCase) -> VortexResult<()> {
let session = VortexSession::empty();
crate::initialize(&session);
let mut ctx = session.create_execution_ctx();
let mut ctx = SESSION.create_execution_ctx();
let case = draw_case(tc, &mut ctx)?;
assert_eq!(case.dtype.serialize_metadata()?, case.metadata);
assert_eq!(
Expand All @@ -148,9 +149,7 @@ mod tests {

#[track_caller]
fn check_native_and_order(tc: &TestCase) -> VortexResult<()> {
let session = VortexSession::empty();
crate::initialize(&session);
let mut ctx = session.create_execution_ctx();
let mut ctx = SESSION.create_execution_ctx();
let case = draw_case(tc, &mut ctx)?;
for (i, expected) in case.source.iter().enumerate() {
let scalar = case.array.execute_scalar(i, &mut ctx)?;
Expand Down
46 changes: 23 additions & 23 deletions vortex-btrblocks/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ use vortex_fastlanes::BitPacked;
use vortex_fastlanes::Delta;
use vortex_onpair::DEFAULT_CONFIG;
use vortex_onpair::OnPair;
#[cfg(feature = "zstd")]
use vortex_session::VortexSession;
use vortex_sparse::Sparse;

Expand Down Expand Up @@ -147,30 +148,30 @@ fn test_container_validity_is_compressed(
) -> VortexResult<()> {
let mut ctx = SESSION.create_execution_ctx();
let validity = Validity::Array(
BoolArray::from_iter((0..100_000).map(|i| (1000..2000).contains(&i))).into_array(),
BoolArray::from_iter((0..4_096).map(|i| (1000..1500).contains(&i))).into_array(),
);
let elements = PrimitiveArray::from_iter(0..100_000i32).into_array();
let elements = PrimitiveArray::from_iter(0..4_096i32).into_array();
let input = match kind {
"struct" => {
StructArray::try_new(["value"].into(), [elements], 100_000, validity)?.into_array()
StructArray::try_new(["value"].into(), [elements], 4_096, validity)?.into_array()
}
"list" => ListArray::try_new(
elements,
PrimitiveArray::from_iter(0..=100_000u32).into_array(),
PrimitiveArray::from_iter(0..=4_096u32).into_array(),
validity,
&mut ctx,
)?
.into_array(),
"listview" => ListViewArray::try_new(
elements,
PrimitiveArray::from_iter(0..100_000u32).into_array(),
PrimitiveArray::from_iter(iter::repeat_n(1u32, 100_000)).into_array(),
PrimitiveArray::from_iter(0..4_096u32).into_array(),
PrimitiveArray::from_iter(iter::repeat_n(1u32, 4_096)).into_array(),
validity,
&mut ctx,
)?
.into_array(),
"fixed_size_list" => {
FixedSizeListArray::try_new(elements, 1, validity, 100_000)?.into_array()
FixedSizeListArray::try_new(elements, 1, validity, 4_096)?.into_array()
}
_ => unreachable!(),
};
Expand All @@ -187,29 +188,29 @@ fn test_leaf_validity_is_compressed(
#[values("bool", "integer", "float", "decimal", "string")] kind: &str,
) -> VortexResult<()> {
let validity = Validity::Array(
BoolArray::from_iter((0..100_000).map(|i| (1000..2000).contains(&i))).into_array(),
BoolArray::from_iter((0..4_096).map(|i| (1000..1500).contains(&i))).into_array(),
);
let input = match kind {
"bool" => BoolArray::new(
BitBuffer::from_iter((0..100_000).map(|i| i % 2 == 0)),
BitBuffer::from_iter((0..4_096).map(|i| i % 2 == 0)),
validity,
)
.into_array(),
"integer" => PrimitiveArray::new(Buffer::from_iter(0..100_000i64), validity).into_array(),
"integer" => PrimitiveArray::new(Buffer::from_iter(0..4_096i64), validity).into_array(),
"float" => PrimitiveArray::new(
Buffer::from_iter((0..100_000).map(|i| f64::from(i) / 3.0)),
Buffer::from_iter((0..4_096).map(|i| f64::from(i) / 3.0)),
validity,
)
.into_array(),
"decimal" => DecimalArray::new(
(0..100_000i64).collect(),
(0..4_096i64).collect(),
DecimalDType::new(12, 2),
validity,
&mut SESSION.create_execution_ctx(),
)
.into_array(),
"string" => VarBinViewArray::from_iter(
(0..100_000).map(|i| (1000..2000).contains(&i).then(|| format!("value-{i}"))),
(0..4_096).map(|i| (1000..1500).contains(&i).then(|| format!("value-{i}"))),
DType::Utf8(Nullability::Nullable),
)
.into_array(),
Expand Down Expand Up @@ -614,7 +615,7 @@ fn test_integer_scheme_compresses_its_validity(
#[case] scheme: &'static dyn Scheme,
) -> VortexResult<()> {
let input = PrimitiveArray::from_option_iter(
(0..100_000i32).map(|i| (!(1000..2000).contains(&i)).then_some(i % 100)),
(0..4_096i32).map(|i| (!(1000..1500).contains(&i)).then_some(i % 100)),
)
.into_array();
let compressor = BtrBlocksCompressorBuilder::empty()
Expand Down Expand Up @@ -665,7 +666,7 @@ fn test_float_scheme_compresses_its_validity(
#[case] scheme: &'static dyn Scheme,
) -> VortexResult<()> {
let input = PrimitiveArray::from_option_iter(
(0..100_000).map(|i| (!(1000..2000).contains(&i)).then(|| f64::from(i).sqrt())),
(0..4_096).map(|i| (!(1000..1500).contains(&i)).then(|| f64::from(i).sqrt())),
)
.into_array();
let compressor = BtrBlocksCompressorBuilder::empty()
Expand Down Expand Up @@ -742,8 +743,8 @@ fn test_bytes_scheme_compresses_its_validity(
#[case] dtype: DType,
) -> VortexResult<()> {
let input = VarBinViewArray::from_iter(
(0..100_000).map(|i| {
(!(1000..2000).contains(&i)).then(|| format!("value-{}", i % 100).into_bytes())
(0..4_096).map(|i| {
(!(1000..1500).contains(&i)).then(|| format!("value-{}", i % 100).into_bytes())
}),
dtype,
)
Expand Down Expand Up @@ -772,14 +773,14 @@ fn test_zstd_compacts_and_compresses_its_validity(
// Values longer than 12 bytes live in the data buffers, and the slice references a tenth of
// them, so compaction rewrites the array.
let input = VarBinViewArray::from_iter(
(0..200_000).map(|i| {
(!(1000..2000).contains(&i))
(0..40_960).map(|i| {
(!(1000..1500).contains(&i))
.then(|| format!("an outlined value {}", i % 100).into_bytes())
}),
dtype,
)
.into_array()
.slice(0..20_000)?;
.slice(0..4_096)?;
let compressor = BtrBlocksCompressorBuilder::empty()
.with_new_scheme(scheme)
.with_new_scheme(&BoolRunEndScheme)
Expand All @@ -796,8 +797,7 @@ fn test_zstd_compacts_and_compresses_its_validity(
#[test]
fn test_varbin_validity_is_compressed() -> VortexResult<()> {
let input = VarBinViewArray::from_iter(
(0..100_000)
.map(|i| (!(1000..2000).contains(&i)).then(|| format!("value-{i}").into_bytes())),
(0..4_096).map(|i| (!(1000..1500).contains(&i)).then(|| format!("value-{i}").into_bytes())),
DType::Binary(Nullability::Nullable),
)
.into_array();
Expand Down Expand Up @@ -912,7 +912,7 @@ impl ChildPolicy for KeepEverything {
#[case::schemes_decide(false)]
#[case::policy_keeps(true)]
fn test_child_policy_overrides_schemes(#[case] keep: bool) -> VortexResult<()> {
let input = PrimitiveArray::from_iter((0..1_000_000).map(|i| i / 100)).into_array();
let input = PrimitiveArray::from_iter((0..8_192).map(|i| i / 8)).into_array();
let mut builder = BtrBlocksCompressorBuilder::empty()
.with_new_scheme(&RunEndScheme)
.with_new_scheme(&BITPACKING_V1);
Expand Down
58 changes: 58 additions & 0 deletions vortex-duckdb/src/e2e_test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,64 @@
//!
//! These tests exercise the registered extension through scans, spatial pushdown, and S3 reads.

#[cfg(test)]
mod spatial_loader {
use std::env;
use std::fs;
use std::fs::OpenOptions;
use std::path::PathBuf;

use vortex::error::VortexResult;

use crate::duckdb::Connection;

fn spatial_extension_dir() -> VortexResult<PathBuf> {
let dir = env::var_os("HOME")
.or_else(|| env::var_os("USERPROFILE"))
.map(|home| {
PathBuf::from(home)
.join(".duckdb")
.join("vortex-test-extensions")
})
.unwrap_or_else(|| env::temp_dir().join("vortex-duckdb-test-extensions"));
fs::create_dir_all(&dir)?;
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Resolved
Ok(dir)
}

/// Loads DuckDB's `spatial` extension, synchronizing one-time installation across threads and
/// processes with a file lock.
pub(crate) fn load_spatial(conn: &Connection) -> VortexResult<()> {
if conn.query("LOAD spatial;").is_ok() {
return Ok(());
}

let ext_dir = spatial_extension_dir()?;
let escaped_dir = ext_dir.to_string_lossy().replace('\'', "''");
conn.query(&format!("SET extension_directory = '{escaped_dir}';"))?;

if conn.query("LOAD spatial;").is_ok() {
return Ok(());
}

let lock_file = OpenOptions::new()
.create(true)
.truncate(false)
.write(true)
.open(ext_dir.join(".spatial.lock"))?;
lock_file.lock()?;

if conn.query("LOAD spatial;").is_ok() {
return Ok(());
}

conn.query("INSTALL spatial; LOAD spatial;")?;
Ok(())
}
}

#[cfg(test)]
pub(crate) use spatial_loader::load_spatial;

#[cfg(test)]
mod s3_test;
#[cfg(all(test, duckdb_release))]
Expand Down
3 changes: 2 additions & 1 deletion vortex-duckdb/src/e2e_test/spatial_pushdown_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use vortex_spatial::extension::Dimension;
use vortex_spatial::extension::Point;
use vortex_spatial::extension::SpatialMetadata;

use super::load_spatial;
use crate::RUNTIME;
use crate::SESSION;
use crate::cpp::duckdb_string_t;
Expand Down Expand Up @@ -86,7 +87,7 @@ fn spatial_database() -> (Database, Connection) {
db.register_vortex_scan_replacement().unwrap();
crate::initialize(&db).unwrap();
let conn = db.connect().unwrap();
conn.query("INSTALL spatial; LOAD spatial;").unwrap();
load_spatial(&conn).unwrap();
// Must follow `LOAD spatial`: the overrides copy spatial's catalog entries.
db.register_spatial_overrides().unwrap();
(db, conn)
Expand Down
Loading
Loading