Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions vortex-array/proto/expr.proto
Original file line number Diff line number Diff line change
Expand Up @@ -153,27 +153,6 @@ message NumericOpts {
}
}

// Options for the legacy `vortex.binary` function. Vortex no longer writes it. A reader converts
// it to `vortex.compare`, `vortex.boolean`, or `vortex.numeric`.
message BinaryOpts {
BinaryOp op = 1;

enum BinaryOp {
Eq = 0;
NotEq = 1;
Gt = 2;
Gte = 3;
Lt = 4;
Lte = 5;
And = 6;
Or = 7;
Add = 8;
Sub = 9;
Mul = 10;
Div = 11;
}
}

message BetweenOpts {
bool lower_strict = 1;
bool upper_strict = 2;
Expand Down
76 changes: 0 additions & 76 deletions vortex-array/src/proto/generated/vortex.expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,82 +335,6 @@ pub mod numeric_opts {
}
}
}
/// Options for the legacy `vortex.binary` function. Vortex no longer writes it. A reader converts
/// it to `vortex.compare`, `vortex.boolean`, or `vortex.numeric`.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct BinaryOpts {
#[prost(enumeration = "binary_opts::BinaryOp", tag = "1")]
pub op: i32,
}
/// Nested message and enum types in `BinaryOpts`.
pub mod binary_opts {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum BinaryOp {
Eq = 0,
NotEq = 1,
Gt = 2,
Gte = 3,
Lt = 4,
Lte = 5,
And = 6,
Or = 7,
Add = 8,
Sub = 9,
Mul = 10,
Div = 11,
}
impl BinaryOp {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Eq => "Eq",
Self::NotEq => "NotEq",
Self::Gt => "Gt",
Self::Gte => "Gte",
Self::Lt => "Lt",
Self::Lte => "Lte",
Self::And => "And",
Self::Or => "Or",
Self::Add => "Add",
Self::Sub => "Sub",
Self::Mul => "Mul",
Self::Div => "Div",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Eq" => Some(Self::Eq),
"NotEq" => Some(Self::NotEq),
"Gt" => Some(Self::Gt),
"Gte" => Some(Self::Gte),
"Lt" => Some(Self::Lt),
"Lte" => Some(Self::Lte),
"And" => Some(Self::And),
"Or" => Some(Self::Or),
"Add" => Some(Self::Add),
"Sub" => Some(Self::Sub),
"Mul" => Some(Self::Mul),
"Div" => Some(Self::Div),
_ => None,
}
}
}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct BetweenOpts {
#[prost(bool, tag = "1")]
Expand Down
57 changes: 4 additions & 53 deletions vortex-array/src/scalar_fn/builtin/binary.rs
Original file line number Diff line number Diff line change
@@ -1,41 +1,25 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

//! Code that the two-operand functions [`Compare`], [`Boolean`], and [`Numeric`] share, and the
//! reader for the legacy `vortex.binary` function.
//! Code that the two-operand functions [`Compare`], [`Boolean`], and [`Numeric`] share.
//!
//! Vortex wrote all three kinds of operation as one `vortex.binary` function with a
//! [`pb::BinaryOpts`] operator. [`LegacyBinary`] reads such a function and returns the function
//! that now owns the operator, so an expression that an older version serialized still loads.
//! [`Compare`]: crate::scalar_fn::builtin::compare::Compare
//! [`Boolean`]: crate::scalar_fn::builtin::boolean::Boolean
//! [`Numeric`]: crate::scalar_fn::builtin::numeric::Numeric

use std::fmt::Display;
use std::fmt::Formatter;

use prost::Message;
use vortex_error::VortexResult;
use vortex_session::VortexSession;
use vortex_session::registry::CachedId;

use crate::AnyColumnar;
use crate::ExecutionCtx;
use crate::matcher::Matcher;
use crate::proto::expr as pb;
use crate::proto::expr::binary_opts::BinaryOp;
use crate::require_input;
use crate::scalar::NumericOperator;
use crate::scalar_fn::ChildName;
use crate::scalar_fn::ExecutionArgs;
use crate::scalar_fn::ScalarFnExecutionResult;
use crate::scalar_fn::ScalarFnId;
use crate::scalar_fn::ScalarFnPlugin;
use crate::scalar_fn::ScalarFnRef;
use crate::scalar_fn::ScalarFnVTable;
use crate::scalar_fn::ScalarFnVTableExt;
use crate::scalar_fn::builtin::boolean::Boolean;
use crate::scalar_fn::builtin::compare::Compare;
use crate::scalar_fn::builtin::numeric::Numeric;
use crate::scalar_fn::builtin::operators::BooleanOperator;
use crate::scalar_fn::builtin::operators::CompareOperator;
use crate::scalar_fn::display::ExprDisplay;

/// Returns the name of an operand of a two-operand function.
Expand Down Expand Up @@ -89,39 +73,6 @@ pub(super) fn execute_strict_step<V: ScalarFnVTable>(
.map(ScalarFnExecutionResult::done)
}

/// The reader for the legacy `vortex.binary` function.
///
/// It is only a [`ScalarFnPlugin`]: no expression or array holds it. Deserialization returns a
/// [`Compare`], [`Boolean`], or [`Numeric`] function, which serializes with its own id.
#[derive(Debug)]
pub(crate) struct LegacyBinary;

impl ScalarFnPlugin for LegacyBinary {
fn id(&self) -> ScalarFnId {
static ID: CachedId = CachedId::new("vortex.binary");
*ID
}

fn deserialize(&self, metadata: &[u8], _session: &VortexSession) -> VortexResult<ScalarFnRef> {
let opts = pb::BinaryOpts::decode(metadata)?;

Ok(match BinaryOp::try_from(opts.op)? {
BinaryOp::Eq => Compare.bind(CompareOperator::Eq.into()),
BinaryOp::NotEq => Compare.bind(CompareOperator::NotEq.into()),
BinaryOp::Gt => Compare.bind(CompareOperator::Gt.into()),
BinaryOp::Gte => Compare.bind(CompareOperator::Gte.into()),
BinaryOp::Lt => Compare.bind(CompareOperator::Lt.into()),
BinaryOp::Lte => Compare.bind(CompareOperator::Lte.into()),
BinaryOp::And => Boolean.bind(BooleanOperator::And),
BinaryOp::Or => Boolean.bind(BooleanOperator::Or),
BinaryOp::Add => Numeric.bind(NumericOperator::Add),
BinaryOp::Sub => Numeric.bind(NumericOperator::Sub),
BinaryOp::Mul => Numeric.bind(NumericOperator::Mul),
BinaryOp::Div => Numeric.bind(NumericOperator::Div),
})
}
}

#[cfg(test)]
mod tests {
use std::sync::LazyLock;
Expand Down
1 change: 0 additions & 1 deletion vortex-array/src/scalar_fn/builtin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
//! [`ArrayBuiltins`]: crate::builtins::ArrayBuiltins

mod binary;
pub(crate) use binary::LegacyBinary;
pub mod boolean;
pub mod cast;
pub mod compare;
Expand Down
5 changes: 0 additions & 5 deletions vortex-array/src/scalar_fn/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use vortex_session::registry::Id;

use crate::scalar_fn::ScalarFnPluginRef;
use crate::scalar_fn::ScalarFnVTable;
use crate::scalar_fn::builtin::LegacyBinary;
use crate::scalar_fn::builtin::boolean::Boolean;
use crate::scalar_fn::builtin::cast::Cast;
use crate::scalar_fn::builtin::compare::Compare;
Expand Down Expand Up @@ -66,10 +65,6 @@ impl Default for ScalarFnSession {
this.register(Numeric);
this.register(Pack);

// Expressions that an older version serialized can hold the legacy `vortex.binary` id.
let legacy_binary = Arc::new(LegacyBinary) as ScalarFnPluginRef;
this.registry.insert(legacy_binary.id(), legacy_binary);

this
}
}
Expand Down
59 changes: 0 additions & 59 deletions vortex-expr/src/tests/legacy_binary.rs

This file was deleted.

1 change: 0 additions & 1 deletion vortex-expr/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ mod expression;
mod fill_null;
mod get_item;
mod is_not_null;
mod legacy_binary;
mod literal;
mod mask;
mod not;
Expand Down
Loading