• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vortex-data / vortex / 16049945385

03 Jul 2025 12:06PM UTC coverage: 77.865% (-0.02%) from 77.885%
16049945385

push

github

web-flow
feat: Hide as many of FieldNames' Arcs as possible (#3747)

The main purpose of this PR is to hide the implementation details of
`FieldNames` from the public API, and pushing all the required
`from/into` calls internally.

The change in API can be seen in all the test changes, which I think are
nicer.

---------

Signed-off-by: Adam Gutglick <adam@spiraldb.com>

138 of 173 new or added lines in 30 files covered. (79.77%)

43324 of 55640 relevant lines covered (77.86%)

55702.55 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/vortex-expr/src/arbitrary.rs
1
use std::cmp::max;
2

3
use arbitrary::{Result as AResult, Unstructured};
4
use vortex_dtype::{DType, FieldName};
5
use vortex_scalar::arbitrary::random_scalar;
6

7
use crate::{BinaryExpr, ExprRef, Operator, and_collect, get_item_scope, lit, pack};
8

9
pub fn projection_expr(u: &mut Unstructured<'_>, dtype: &DType) -> AResult<Option<ExprRef>> {
×
10
    let Some(struct_dtype) = dtype.as_struct() else {
×
11
        return Ok(None);
×
12
    };
13

14
    let column_count = u.int_in_range::<usize>(0..=max(struct_dtype.nfields(), 10))?;
×
15

16
    let cols = (0..column_count)
×
17
        .map(|_| {
×
NEW
18
            let get_item = u.choose_iter(struct_dtype.names().iter())?;
×
19
            Ok((get_item.clone(), get_item_scope(get_item.clone())))
×
20
        })
×
21
        .collect::<AResult<Vec<_>>>()?;
×
22

23
    Ok(Some(pack(cols, u.arbitrary()?)))
×
24
}
×
25

26
pub fn filter_expr(u: &mut Unstructured<'_>, dtype: &DType) -> AResult<Option<ExprRef>> {
×
27
    let Some(struct_dtype) = dtype.as_struct() else {
×
28
        return Ok(None);
×
29
    };
30

31
    let filter_count = u.int_in_range::<usize>(0..=max(struct_dtype.nfields(), 10))?;
×
32

33
    let filters = (0..filter_count)
×
34
        .map(|_| {
×
35
            let (col, dtype) =
×
36
                u.choose_iter(struct_dtype.names().iter().zip(struct_dtype.fields()))?;
×
37
            random_comparison(u, col, &dtype)
×
38
        })
×
39
        .collect::<AResult<Vec<_>>>()?;
×
40

41
    Ok(and_collect(filters))
×
42
}
×
43

44
fn random_comparison(u: &mut Unstructured<'_>, col: &FieldName, dtype: &DType) -> AResult<ExprRef> {
×
45
    let scalar = random_scalar(u, dtype)?;
×
46
    Ok(BinaryExpr::new_expr(
47
        get_item_scope(col.clone()),
×
48
        arbitrary_comparison_operator(u)?,
×
49
        lit(scalar),
×
50
    ))
51
}
×
52

53
fn arbitrary_comparison_operator(u: &mut Unstructured<'_>) -> AResult<Operator> {
×
54
    Ok(match u.int_in_range(0..=5)? {
×
55
        0 => Operator::Eq,
×
56
        1 => Operator::NotEq,
×
57
        2 => Operator::Gt,
×
58
        3 => Operator::Gte,
×
59
        4 => Operator::Lt,
×
60
        5 => Operator::Lte,
×
61
        _ => unreachable!("range 0..=5"),
×
62
    })
63
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc