Skip to content

Commit a5a563e

Browse files
committed
Overtime events
1 parent ce2a544 commit a5a563e

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

vortex-expr/src/exprs/get_item.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,23 @@ impl VTable for GetItem {
6565
}
6666

6767
fn return_dtype(&self, expr: &ExpressionView<Self>, scope: &DType) -> VortexResult<DType> {
68-
let input = expr.children()[0].return_dtype(scope)?;
69-
input
68+
let struct_dtype = expr.children()[0].return_dtype(scope)?;
69+
let field_dtype = struct_dtype
7070
.as_struct_fields_opt()
7171
.and_then(|st| st.field(expr.data()))
72-
.map(|f| f.union_nullability(input.nullability()))
7372
.ok_or_else(|| {
7473
vortex_err!("Couldn't find the {} field in the input scope", expr.data())
75-
})
74+
})?;
75+
76+
// Match here to avoid cloning the dtype if nullability doesn't need to change
77+
if matches!(
78+
(struct_dtype.nullability(), field_dtype.nullability()),
79+
(Nullability::Nullable, Nullability::NonNullable)
80+
) {
81+
return Ok(field_dtype.with_nullability(Nullability::Nullable));
82+
}
83+
84+
Ok(field_dtype)
7685
}
7786

7887
fn evaluate(&self, expr: &ExpressionView<Self>, scope: &ArrayRef) -> VortexResult<ArrayRef> {

vortex-expr/src/view.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ impl<'a, V: VTable> ExpressionView<'a, V> {
2121
/// # Panics
2222
///
2323
/// Panics if the expression cannot be downcast to the specified vtable type.
24+
#[inline]
2425
pub fn new(expression: &'a Expression) -> Self {
2526
Self::try_new(expression).vortex_expect("Failed to downcast expression")
2627
}
2728

2829
/// Attempts to wrap up the given expression as an [`ExpressionView`] of the specified vtable type.
30+
#[inline]
2931
pub fn try_new(expression: &'a Expression) -> VortexResult<Self> {
3032
expression.vtable().as_opt::<V>().ok_or_else(|| {
3133
vortex_err!(

vortex-expr/src/vtable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,12 @@ pub trait DynExprVTable: 'static + Send + Sync + private::Sealed {
195195
pub struct VTableAdapter<V>(V);
196196

197197
impl<V: VTable> DynExprVTable for VTableAdapter<V> {
198+
#[inline(always)]
198199
fn as_any(&self) -> &dyn Any {
199200
self
200201
}
201202

203+
#[inline(always)]
202204
fn id(&self) -> ExprId {
203205
V::id(&self.0)
204206
}

0 commit comments

Comments
 (0)