pub struct ExpressionView<'a, V: VTable> { /* private fields */ }Expand description
A view over an Expression with an associated vtable, allowing typed access to the
expression’s instance data.
Implementations§
Source§impl ExpressionView<'_, Between>
impl ExpressionView<'_, Between>
pub fn child(&self) -> &Expression
pub fn lower(&self) -> &Expression
pub fn upper(&self) -> &Expression
pub fn to_binary_expr(&self) -> Expression
Source§impl ExpressionView<'_, Binary>
impl ExpressionView<'_, Binary>
pub fn lhs(&self) -> &Expression
pub fn rhs(&self) -> &Expression
pub fn operator(&self) -> Operator
Source§impl ExpressionView<'_, DynamicComparison>
impl ExpressionView<'_, DynamicComparison>
Source§impl ExpressionView<'_, ListContains>
impl ExpressionView<'_, ListContains>
pub fn list(&self) -> &Expression
pub fn needle(&self) -> &Expression
Source§impl ExpressionView<'_, Pack>
impl ExpressionView<'_, Pack>
pub fn field(&self, field_name: &FieldName) -> VortexResult<Expression>
Source§impl ExpressionView<'_, Select>
impl ExpressionView<'_, Select>
pub fn child(&self) -> &Expression
Sourcepub fn as_include(&self, field_names: &FieldNames) -> VortexResult<Expression>
pub fn as_include(&self, field_names: &FieldNames) -> VortexResult<Expression>
Turn the select expression into an include, relative to a provided array of field names.
For example:
let field_names = FieldNames::from(["a", "b", "c"]);
let include = select(["a"], root());
let exclude = select_exclude(["b", "c"], root());
assert_eq!(
&include.as_::<Select>().as_include(&field_names).unwrap(),
&exclude.as_::<Select>().as_include(&field_names).unwrap(),
);Source§impl<'a, V: VTable> ExpressionView<'a, V>
impl<'a, V: VTable> ExpressionView<'a, V>
Sourcepub fn new(expression: &'a Expression) -> Self
pub fn new(expression: &'a Expression) -> Self
Wrap up the given expression as an ExpressionView of the specified vtable type.
§Panics
Panics if the expression cannot be downcast to the specified vtable type.
Sourcepub fn maybe_new(expression: &'a Expression) -> Option<Self>
pub fn maybe_new(expression: &'a Expression) -> Option<Self>
Attempts to wrap up the given expression as an ExpressionView of the specified vtable type.
Methods from Deref<Target = Expression>§
Sourcepub fn is<V: VTable>(&self) -> bool
pub fn is<V: VTable>(&self) -> bool
Returns if the expression is an instance of the given vtable.
Sourcepub fn as_<V: VTable>(&self) -> ExpressionView<'_, V>
pub fn as_<V: VTable>(&self) -> ExpressionView<'_, V>
Returns a typed view of this expression for the given vtable.
§Panics
Panics if the expression’s encoding or metadata cannot be cast to the specified vtable.
Sourcepub fn as_opt<V: VTable>(&self) -> Option<ExpressionView<'_, V>>
pub fn as_opt<V: VTable>(&self) -> Option<ExpressionView<'_, V>>
Returns a typed view of this expression for the given vtable, if the types match.
Sourcepub fn vtable(&self) -> &ExprVTable
pub fn vtable(&self) -> &ExprVTable
Returns the expression’s vtable.
Sourcepub fn children(&self) -> &Arc<[Expression]>
pub fn children(&self) -> &Arc<[Expression]>
Returns the children of this expression.
Sourcepub fn child(&self, n: usize) -> &Expression
pub fn child(&self, n: usize) -> &Expression
Returns the n’th child of this expression.
Sourcepub fn child_name(&self, n: usize) -> ChildName
pub fn child_name(&self, n: usize) -> ChildName
Returns the name of the n’th child of this expression.
Sourcepub fn serialize_metadata(&self) -> VortexResult<Option<Vec<u8>>>
pub fn serialize_metadata(&self) -> VortexResult<Option<Vec<u8>>>
Returns the serialized metadata for this expression.
Sourcepub fn return_dtype(&self, scope: &DType) -> VortexResult<DType>
pub fn return_dtype(&self, scope: &DType) -> VortexResult<DType>
Computes the return dtype of this expression given the input dtype.
Sourcepub fn evaluate(&self, scope: &ArrayRef) -> VortexResult<ArrayRef>
pub fn evaluate(&self, scope: &ArrayRef) -> VortexResult<ArrayRef>
Evaluates the expression in the given scope.
Sourcepub fn stat_falsification(
&self,
catalog: &mut dyn StatsCatalog,
) -> Option<Expression>
pub fn stat_falsification( &self, catalog: &mut dyn StatsCatalog, ) -> Option<Expression>
An expression over zone-statistics which implies all records in the zone evaluate to false.
Given an expression, e, if e.stat_falsification(..) evaluates to true, it is guaranteed
that e evaluates to false on all records in the zone. However, the inverse is not
necessarily true: even if the falsification evaluates to false, e need not evaluate to
true on all records.
The StatsCatalog can be used to constrain or rename stats used in the final expr.
§Examples
- An expression over one variable:
x > 0is false for all records in a zone if the maximum value of the columnxin that zone is less than or equal to zero:max(x) <= 0. - An expression over two variables:
x > ybecomesmax(x) <= min(y). - A conjunctive expression:
x > y AND z < xbecomes `max(x) <= min(y) OR min(z) >= max(x).
Some expressions, in theory, have falsifications but this function does not support them
such as x < (y < z) or x LIKE "needle%".
Sourcepub fn stat_max(&self, catalog: &mut dyn StatsCatalog) -> Option<Expression>
pub fn stat_max(&self, catalog: &mut dyn StatsCatalog) -> Option<Expression>
An expression for the upper non-null bound of this expression, if available.
This function returns None if there is no upper bound, or it is difficult to compute.
The returned expression evaluates to null if the maximum value is unknown. In that case, you must not assume the array is empty nor may you assume the array only contains non-null values.
Sourcepub fn stat_min(&self, catalog: &mut dyn StatsCatalog) -> Option<Expression>
pub fn stat_min(&self, catalog: &mut dyn StatsCatalog) -> Option<Expression>
An expression for the lower non-null bound of this expression, if available.
See Expression::stat_max for important details.
Sourcepub fn stat_nan_count(
&self,
catalog: &mut dyn StatsCatalog,
) -> Option<Expression>
pub fn stat_nan_count( &self, catalog: &mut dyn StatsCatalog, ) -> Option<Expression>
An expression for the NaN count for a column, if available.
This method returns None if the NaNCount stat is unknown.
pub fn stat_field_path(&self) -> Option<FieldPath>
Sourcepub fn fmt_sql(&self, f: &mut Formatter<'_>) -> Result
pub fn fmt_sql(&self, f: &mut Formatter<'_>) -> Result
Format the expression as a compact string.
Since this is a recursive formatter, it is exposed on the public Expression type. See fmt_data that is only implemented on the vtable trait.
Sourcepub fn fmt_data(&self, f: &mut Formatter<'_>) -> Result
pub fn fmt_data(&self, f: &mut Formatter<'_>) -> Result
Format the instance data of the expression as a string for rendering..
Sourcepub fn display_tree(&self) -> impl Display
pub fn display_tree(&self) -> impl Display
Display the expression as a formatted tree structure.
This provides a hierarchical view of the expression that shows the relationships between parent and child expressions, making complex nested expressions easier to understand and debug.
§Example
// Build a complex nested expression
let complex_expr = select(
["result"],
and(
not(eq(get_item("status", root()), lit("inactive"))),
and(
Like.new_expr(LikeOptions::default(), [get_item("name", root()), lit("%admin%")]),
gt(
cast(get_item("score", root()), DType::Primitive(PType::F64, Nullability::NonNullable)),
lit(75.0)
)
)
)
);
println!("{}", complex_expr.display_tree());This produces output like:
Select(include): {result}
└── Binary(and)
├── lhs: Not
│ └── Binary(=)
│ ├── lhs: GetItem(status)
│ │ └── Root
│ └── rhs: Literal(value: "inactive", dtype: utf8)
└── rhs: Binary(and)
├── lhs: Like
│ ├── child: GetItem(name)
│ │ └── Root
│ └── pattern: Literal(value: "%admin%", dtype: utf8)
└── rhs: Binary(>)
├── lhs: Cast(target: f64)
│ └── GetItem(score)
│ └── Root
└── rhs: Literal(value: 75f64, dtype: f64)Trait Implementations§
Auto Trait Implementations§
impl<'a, V> Freeze for ExpressionView<'a, V>
impl<'a, V> !RefUnwindSafe for ExpressionView<'a, V>
impl<'a, V> Send for ExpressionView<'a, V>
impl<'a, V> Sync for ExpressionView<'a, V>
impl<'a, V> Unpin for ExpressionView<'a, V>
impl<'a, V> !UnwindSafe for ExpressionView<'a, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.