Skip to main content

vortex_array/scalar_fn/
signature.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use crate::dtype::FieldName;
5use crate::scalar_fn::Arity;
6use crate::scalar_fn::ChildName;
7use crate::scalar_fn::typed::DynScalarFn;
8
9/// Information about the signature of an expression.
10pub struct ScalarFnSignature<'a> {
11    pub(super) inner: &'a dyn DynScalarFn,
12}
13
14impl ScalarFnSignature<'_> {
15    /// Returns the arity of this expression.
16    pub fn arity(&self) -> Arity {
17        self.inner.arity()
18    }
19
20    /// Returns the name of the nth child of this expression.
21    pub fn child_name(&self, index: usize) -> ChildName {
22        self.inner.child_name(index)
23    }
24
25    /// Returns whether this expression itself is strict.
26    /// See [`crate::scalar_fn::ScalarFnVTable::is_strict`].
27    pub fn is_strict(&self) -> bool {
28        self.inner.is_strict()
29    }
30
31    /// Returns whether this expression itself is infallible.
32    /// See [`crate::scalar_fn::ScalarFnVTable::is_infallible`].
33    pub fn is_infallible(&self) -> bool {
34        self.inner.is_infallible()
35    }
36
37    /// Returns the child whose field `field` this expression passes through unchanged.
38    /// See [`crate::scalar_fn::ScalarFnVTable::forwarded_field`].
39    pub fn forwarded_field(&self, field: &FieldName) -> Option<usize> {
40        self.inner.forwarded_field(field)
41    }
42}