Skip to content

Commit 4193db3

Browse files
fix(vortex-array): decouple row operation fallibility
Signed-off-by: Nemo Yu <[email protected]>
1 parent 70571c4 commit 4193db3

5 files changed

Lines changed: 11 additions & 11 deletions

File tree

‎vortex-array/src/scalar_fn/unstable/row/row_fn.rs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,15 @@ pub trait RowFn: 'static + Sized + Clone + Send + Sync {
4747
/// The arguments in display order. Its length is the function's exact arity.
4848
const ARG_NAMES: &'static [&'static str];
4949

50-
/// Whether every dispatch is infallible.
50+
/// Whether the row operation selected by every dispatch is infallible.
5151
///
5252
/// See [`ScalarFnVTable::is_infallible`](crate::scalar_fn::ScalarFnVTable::is_infallible) for
5353
/// a more detailed explanation of semantic errors.
5454
///
55-
/// The framework checks dispatched element and result types. A conservative `false` is allowed.
55+
/// Input decoding fallibility is declared separately by
56+
/// [`InputElement::DECODE_INFALLIBLE`](crate::scalar_fn::unstable::row::InputElement::DECODE_INFALLIBLE)
57+
/// and does not affect this flag. The framework checks dispatched result types. A conservative
58+
/// `false` is allowed.
5659
const INFALLIBLE: bool;
5760

5861
/// Returns the ID of the scalar function.

‎vortex-array/src/scalar_fn/unstable/row/types/element/input.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ pub unsafe trait InputElement: 'static {
4747
/// Whether [`decode`](Self::decode) is infallible for _legal_ input data.
4848
///
4949
/// This excludes infrastructural failures such as IO or allocation.
50+
/// It is independent of
51+
/// [`RowFn::INFALLIBLE`](crate::scalar_fn::unstable::row::RowFn::INFALLIBLE), which describes
52+
/// the row operation rather than input decoding.
5053
const DECODE_INFALLIBLE: bool;
5154

5255
/// Validate that `dtype` is an acceptable input column dtype for this element type.

‎vortex-array/src/scalar_fn/unstable/row/visitor/check.rs‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ const fn assert_input_visit_contract<F: RowFn, Args: ElementTuple>() {
3333
Args::ARITY == F::ARG_NAMES.len(),
3434
"the visited argument tuple must have the arity declared by RowFn::ARG_NAMES",
3535
);
36-
// Dictionary push-down can evaluate values that no input row references. Every dispatch must
37-
// therefore match the function-wide fallibility declaration.
38-
assert!(
39-
Args::DECODE_INFALLIBLE || !F::INFALLIBLE,
40-
"RowFn::INFALLIBLE must be false when input decoding can fail",
41-
);
4236
}
4337

4438
pub(super) const fn assert_owned_visit_contract<Function, Args, Out>()

‎vortex-array/src/scalar_fn/unstable/row/visitor/row_visitor.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ use crate::scalar_fn::unstable::row::SinkResult;
2222
///
2323
/// Only the framework implements this trait. The `visit_prepared*` methods derive shared state
2424
/// from constant arguments before visiting any rows. Every visit verifies that the argument tuple
25-
/// matches [`RowFn::ARG_NAMES`] and that fallible decoding agrees with [`RowFn::INFALLIBLE`].
25+
/// matches [`RowFn::ARG_NAMES`] and that row-result fallibility agrees with
26+
/// [`RowFn::INFALLIBLE`]. Input decoding declares its fallibility independently.
2627
///
2728
/// A visit selects the _storage dtype_, the dtype the chosen [`OutputElement`] or [`OutputSink`]
2829
/// physically builds. [`with_output_dtype`](Self::with_output_dtype) declares the _output dtype_,

‎vortex-spatial/src/scalar_fn/distance.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ impl RowFn for SpatialDistance {
3939
type Options = EmptyOptions;
4040

4141
const ARG_NAMES: &'static [&'static str] = &["a", "b"];
42-
// The per-row distance cannot fail, but decoding a geometry operand can.
43-
const INFALLIBLE: bool = false;
42+
const INFALLIBLE: bool = true;
4443

4544
fn id(&self) -> ScalarFnId {
4645
static ID: CachedId = CachedId::new("vortex.st.distance");

0 commit comments

Comments
 (0)