Skip to content

Commit 6af44bb

Browse files
committed
Clarify docs in session accessors
Signed-off-by: Nicholas Gates <[email protected]>
1 parent 64781ba commit 6af44bb

File tree

9 files changed

+112
-187
lines changed

9 files changed

+112
-187
lines changed

vortex-array/src/arrays/scalar_fn/vtable/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,15 @@ use std::ops::Deref;
1313
use itertools::Itertools;
1414
use vortex_buffer::BufferHandle;
1515
use vortex_dtype::DType;
16-
use vortex_error::VortexResult;
1716
use vortex_error::vortex_bail;
1817
use vortex_error::vortex_ensure;
18+
use vortex_error::VortexResult;
1919

20-
use crate::Array;
21-
use crate::ArrayRef;
22-
use crate::IntoArray;
23-
use crate::arrays::ConstantVTable;
2420
use crate::arrays::scalar_fn::array::ScalarFnArray;
2521
use crate::arrays::scalar_fn::kernel::KernelInput;
2622
use crate::arrays::scalar_fn::kernel::ScalarFnKernel;
2723
use crate::arrays::scalar_fn::metadata::ScalarFnMetadata;
24+
use crate::arrays::ConstantVTable;
2825
use crate::expr;
2926
use crate::expr::ExprVTable;
3027
use crate::expr::ScalarFn;
@@ -39,6 +36,9 @@ use crate::vtable::ArrayVTable;
3936
use crate::vtable::ArrayVTableExt;
4037
use crate::vtable::NotSupported;
4138
use crate::vtable::VTable;
39+
use crate::Array;
40+
use crate::ArrayRef;
41+
use crate::IntoArray;
4242

4343
vtable!(ScalarFn);
4444

vortex-array/src/arrays/struct_/rules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::ArrayRef;
2121
use crate::IntoArray;
2222

2323
#[derive(Debug)]
24-
pub struct StructGetItemRule;
24+
pub(crate) struct StructGetItemRule;
2525
impl ArrayParentReduceRule<Exact<StructVTable>, ExactScalarFn<GetItem>> for StructGetItemRule {
2626
fn child(&self) -> Exact<StructVTable> {
2727
Exact::from(&StructVTable)

vortex-array/src/executor.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ impl VectorExecutor for ArrayRef {
3636
}
3737

3838
fn execute_datum(&self, session: &VortexSession) -> VortexResult<Datum> {
39-
log::error!("Executing array: {}", self.display_tree());
40-
4139
// Attempt to short-circuit constant arrays.
4240
if let Some(constant) = self.as_opt::<ConstantVTable>() {
4341
return Ok(Datum::Scalar(constant.scalar().to_vector_scalar()));

vortex-array/src/expr/exprs/binary.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ use prost::Message;
88
use vortex_compute::arrow::IntoArrow;
99
use vortex_compute::arrow::IntoVector;
1010
use vortex_dtype::DType;
11-
use vortex_error::VortexExpect;
12-
use vortex_error::VortexResult;
1311
use vortex_error::vortex_bail;
1412
use vortex_error::vortex_err;
13+
use vortex_error::VortexExpect;
14+
use vortex_error::VortexResult;
1515
use vortex_proto::expr as pb;
1616
use vortex_vector::Datum;
17+
use vortex_vector::VectorOps;
1718

18-
use crate::ArrayRef;
1919
use crate::compute;
2020
use crate::compute::add;
2121
use crate::compute::and_kleene;
@@ -24,17 +24,18 @@ use crate::compute::div;
2424
use crate::compute::mul;
2525
use crate::compute::or_kleene;
2626
use crate::compute::sub;
27+
use crate::expr::expression::Expression;
28+
use crate::expr::exprs::literal::lit;
29+
use crate::expr::exprs::operators::Operator;
30+
use crate::expr::stats::Stat;
2731
use crate::expr::Arity;
2832
use crate::expr::ChildName;
2933
use crate::expr::ExecutionArgs;
3034
use crate::expr::ExprId;
3135
use crate::expr::StatsCatalog;
3236
use crate::expr::VTable;
3337
use crate::expr::VTableExt;
34-
use crate::expr::expression::Expression;
35-
use crate::expr::exprs::literal::lit;
36-
use crate::expr::exprs::operators::Operator;
37-
use crate::expr::stats::Stat;
38+
use crate::ArrayRef;
3839

3940
pub struct Binary;
4041

@@ -187,6 +188,11 @@ impl VTable for Binary {
187188
}
188189
};
189190

191+
// Arrow computed over scalar datums
192+
if vector.len() == 1 && args.row_count != 1 {
193+
return Ok(Datum::Scalar(vector.scalar_at(0)));
194+
}
195+
190196
Ok(Datum::Vector(vector))
191197
}
192198

@@ -583,10 +589,10 @@ mod tests {
583589
use super::lt_eq;
584590
use super::not_eq;
585591
use super::or;
586-
use crate::expr::Expression;
587592
use crate::expr::exprs::get_item::col;
588593
use crate::expr::exprs::literal::lit;
589594
use crate::expr::test_harness;
595+
use crate::expr::Expression;
590596

591597
#[test]
592598
fn and_collect_left_assoc() {

vortex-array/src/expr/vtable.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::fmt::Display;
88
use std::fmt::Formatter;
99
use std::hash::Hash;
1010
use std::hash::Hasher;
11-
use std::ops::Deref;
1211
use std::sync::Arc;
1312

1413
use arcref::ArcRef;
@@ -344,7 +343,7 @@ pub struct VTableAdapter<V>(V);
344343
impl<V: VTable> DynExprVTable for VTableAdapter<V> {
345344
#[inline(always)]
346345
fn as_any(&self) -> &dyn Any {
347-
self
346+
&self.0
348347
}
349348

350349
#[inline(always)]
@@ -422,7 +421,8 @@ impl<V: VTable> DynExprVTable for VTableAdapter<V> {
422421
assert_eq!(
423422
v.len(),
424423
expected_row_count,
425-
"Expression execution returned vector of length {}, but expected {}",
424+
"Expression execution {} returned vector of length {}, but expected {}",
425+
self.0.id(),
426426
v.len(),
427427
expected_row_count,
428428
);
@@ -431,7 +431,6 @@ impl<V: VTable> DynExprVTable for VTableAdapter<V> {
431431
// In debug mode, validate that the output dtype matches the expected return dtype.
432432
#[cfg(debug_assertions)]
433433
{
434-
use vortex_error::vortex_ensure;
435434
use vortex_vector::datum_matches_dtype;
436435

437436
if !datum_matches_dtype(&result, &expected_dtype) {
@@ -441,12 +440,6 @@ impl<V: VTable> DynExprVTable for VTableAdapter<V> {
441440
result
442441
);
443442
}
444-
445-
vortex_ensure!(
446-
datum_matches_dtype(&result, &expected_dtype),
447-
"Expression execution invalid for dtype {}",
448-
expected_dtype
449-
);
450443
}
451444

452445
Ok(result)
@@ -537,7 +530,7 @@ impl ExprVTable {
537530

538531
/// Return the vtable as an Any reference.
539532
pub fn as_any(&self) -> &dyn Any {
540-
self.0.deref().as_any()
533+
self.0.as_any()
541534
}
542535

543536
/// Creates a new [`ExprVTable`] from a vtable.
@@ -560,7 +553,7 @@ impl ExprVTable {
560553

561554
/// Returns whether this vtable is of a given type.
562555
pub fn is<V: VTable>(&self) -> bool {
563-
self.0.as_any().is::<VTableAdapter<V>>()
556+
self.0.as_any().is::<V>()
564557
}
565558

566559
/// Deserialize an options of this expression vtable from metadata.

0 commit comments

Comments
 (0)