Skip to content

Commit a9a3a2c

Browse files
committed
fix
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent 238e467 commit a9a3a2c

1 file changed

Lines changed: 7 additions & 40 deletions

File tree

vortex-array/src/expr/optimize.rs

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -313,67 +313,34 @@ impl ReduceCtx for ExpressionReduceCtx {
313313
}
314314

315315
#[cfg(test)]
316-
#[expect(clippy::cast_possible_truncation)]
317316
mod tests {
318-
use std::time::Instant;
319-
320317
use vortex_error::VortexResult;
321318

322319
use crate::dtype::DType;
323320
use crate::dtype::Nullability;
324321
use crate::dtype::PType;
325322
use crate::dtype::StructFields;
326-
use crate::expr::Expression;
327323
use crate::expr::eq;
328324
use crate::expr::get_item;
329325
use crate::expr::lit;
330326
use crate::expr::or;
331327
use crate::expr::root;
332328

333-
fn build_large_or_chain(n: usize) -> Expression {
334-
let base = eq(get_item("x", root()), lit(0i32));
335-
(1..n).fold(base, |acc, i| or(acc, eq(get_item("x", root()), lit(i as i32))))
336-
}
337-
338-
fn struct_scope() -> DType {
339-
DType::Struct(
340-
StructFields::new(
341-
["x"].into(),
342-
vec![DType::Primitive(PType::I32, Nullability::NonNullable)],
343-
),
344-
Nullability::NonNullable,
345-
)
346-
}
347-
348-
#[test]
349-
fn optimize_large_or_chain_does_not_hang() -> VortexResult<()> {
350-
let expr = build_large_or_chain(200);
351-
let scope = struct_scope();
352-
353-
let start = Instant::now();
354-
let _result = expr.optimize_recursive(&scope)?;
355-
let elapsed = start.elapsed();
356-
357-
// This should complete in well under a second. Before the fix, 200 ORs could take
358-
// many seconds due to per-node cache recreation and repeated find_between calls.
359-
assert!(
360-
elapsed.as_secs() < 5,
361-
"optimize_recursive took {elapsed:?} for 200 ORs — regression detected"
362-
);
363-
Ok(())
364-
}
365-
366329
#[test]
367330
fn optimize_or_chain_correctness() -> VortexResult<()> {
368-
// Verify the optimizer still produces correct results for a small OR chain.
369331
let expr = or(
370332
eq(get_item("x", root()), lit(1i32)),
371333
eq(get_item("x", root()), lit(2i32)),
372334
);
373-
let scope = struct_scope();
335+
let scope = DType::Struct(
336+
StructFields::new(
337+
["x"].into(),
338+
vec![DType::Primitive(PType::I32, Nullability::NonNullable)],
339+
),
340+
Nullability::NonNullable,
341+
);
374342
let optimized = expr.optimize_recursive(&scope)?;
375343

376-
// The expression should still reference column "x" and both literals.
377344
let s = optimized.to_string();
378345
assert!(s.contains("$.x"), "expected $.x in {s}");
379346
assert!(s.contains("1i32") || s.contains('1'), "expected 1 in {s}");

0 commit comments

Comments
 (0)