Skip to content
Draft
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
24 changes: 12 additions & 12 deletions vortex-array/public-api.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16176,7 +16176,7 @@ pub fn vortex_array::scalar_fn::fns::fill_null::FillNull::deserialize(&self, _me

pub fn vortex_array::scalar_fn::fns::fill_null::FillNull::execute(&self, _options: &Self::Options, args: &dyn vortex_array::scalar_fn::ExecutionArgs, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::ArrayRef>

pub fn vortex_array::scalar_fn::fns::fill_null::FillNull::fmt_sql(&self, _options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
pub fn vortex_array::scalar_fn::fns::fill_null::FillNull::fmt_sql(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

pub fn vortex_array::scalar_fn::fns::fill_null::FillNull::id(&self) -> vortex_array::scalar_fn::ScalarFnId

Expand Down Expand Up @@ -16332,7 +16332,7 @@ pub fn vortex_array::scalar_fn::fns::is_null::IsNull::deserialize(&self, _metada

pub fn vortex_array::scalar_fn::fns::is_null::IsNull::execute(&self, _data: &Self::Options, args: &dyn vortex_array::scalar_fn::ExecutionArgs, _ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::ArrayRef>

pub fn vortex_array::scalar_fn::fns::is_null::IsNull::fmt_sql(&self, _options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
pub fn vortex_array::scalar_fn::fns::is_null::IsNull::fmt_sql(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

pub fn vortex_array::scalar_fn::fns::is_null::IsNull::id(&self) -> vortex_array::scalar_fn::ScalarFnId

Expand Down Expand Up @@ -16504,7 +16504,7 @@ pub fn vortex_array::scalar_fn::fns::list_contains::ListContains::deserialize(&s

pub fn vortex_array::scalar_fn::fns::list_contains::ListContains::execute(&self, _options: &Self::Options, args: &dyn vortex_array::scalar_fn::ExecutionArgs, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::ArrayRef>

pub fn vortex_array::scalar_fn::fns::list_contains::ListContains::fmt_sql(&self, _options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
pub fn vortex_array::scalar_fn::fns::list_contains::ListContains::fmt_sql(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

pub fn vortex_array::scalar_fn::fns::list_contains::ListContains::id(&self) -> vortex_array::scalar_fn::ScalarFnId

Expand Down Expand Up @@ -16636,7 +16636,7 @@ pub fn vortex_array::scalar_fn::fns::mask::Mask::deserialize(&self, _metadata: &

pub fn vortex_array::scalar_fn::fns::mask::Mask::execute(&self, _options: &Self::Options, args: &dyn vortex_array::scalar_fn::ExecutionArgs, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::ArrayRef>

pub fn vortex_array::scalar_fn::fns::mask::Mask::fmt_sql(&self, _options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
pub fn vortex_array::scalar_fn::fns::mask::Mask::fmt_sql(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

pub fn vortex_array::scalar_fn::fns::mask::Mask::id(&self) -> vortex_array::scalar_fn::ScalarFnId

Expand Down Expand Up @@ -16814,7 +16814,7 @@ pub fn vortex_array::scalar_fn::fns::merge::Merge::deserialize(&self, _metadata:

pub fn vortex_array::scalar_fn::fns::merge::Merge::execute(&self, options: &Self::Options, args: &dyn vortex_array::scalar_fn::ExecutionArgs, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::ArrayRef>

pub fn vortex_array::scalar_fn::fns::merge::Merge::fmt_sql(&self, _options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
pub fn vortex_array::scalar_fn::fns::merge::Merge::fmt_sql(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

pub fn vortex_array::scalar_fn::fns::merge::Merge::id(&self) -> vortex_array::scalar_fn::ScalarFnId

Expand Down Expand Up @@ -16860,7 +16860,7 @@ pub fn vortex_array::scalar_fn::fns::not::Not::deserialize(&self, _metadata: &[u

pub fn vortex_array::scalar_fn::fns::not::Not::execute(&self, _data: &Self::Options, args: &dyn vortex_array::scalar_fn::ExecutionArgs, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::ArrayRef>

pub fn vortex_array::scalar_fn::fns::not::Not::fmt_sql(&self, _options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
pub fn vortex_array::scalar_fn::fns::not::Not::fmt_sql(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

pub fn vortex_array::scalar_fn::fns::not::Not::id(&self) -> vortex_array::scalar_fn::ScalarFnId

Expand Down Expand Up @@ -18030,7 +18030,7 @@ pub fn vortex_array::scalar_fn::fns::fill_null::FillNull::deserialize(&self, _me

pub fn vortex_array::scalar_fn::fns::fill_null::FillNull::execute(&self, _options: &Self::Options, args: &dyn vortex_array::scalar_fn::ExecutionArgs, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::ArrayRef>

pub fn vortex_array::scalar_fn::fns::fill_null::FillNull::fmt_sql(&self, _options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
pub fn vortex_array::scalar_fn::fns::fill_null::FillNull::fmt_sql(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

pub fn vortex_array::scalar_fn::fns::fill_null::FillNull::id(&self) -> vortex_array::scalar_fn::ScalarFnId

Expand Down Expand Up @@ -18106,7 +18106,7 @@ pub fn vortex_array::scalar_fn::fns::is_null::IsNull::deserialize(&self, _metada

pub fn vortex_array::scalar_fn::fns::is_null::IsNull::execute(&self, _data: &Self::Options, args: &dyn vortex_array::scalar_fn::ExecutionArgs, _ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::ArrayRef>

pub fn vortex_array::scalar_fn::fns::is_null::IsNull::fmt_sql(&self, _options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
pub fn vortex_array::scalar_fn::fns::is_null::IsNull::fmt_sql(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

pub fn vortex_array::scalar_fn::fns::is_null::IsNull::id(&self) -> vortex_array::scalar_fn::ScalarFnId

Expand Down Expand Up @@ -18182,7 +18182,7 @@ pub fn vortex_array::scalar_fn::fns::list_contains::ListContains::deserialize(&s

pub fn vortex_array::scalar_fn::fns::list_contains::ListContains::execute(&self, _options: &Self::Options, args: &dyn vortex_array::scalar_fn::ExecutionArgs, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::ArrayRef>

pub fn vortex_array::scalar_fn::fns::list_contains::ListContains::fmt_sql(&self, _options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
pub fn vortex_array::scalar_fn::fns::list_contains::ListContains::fmt_sql(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

pub fn vortex_array::scalar_fn::fns::list_contains::ListContains::id(&self) -> vortex_array::scalar_fn::ScalarFnId

Expand Down Expand Up @@ -18258,7 +18258,7 @@ pub fn vortex_array::scalar_fn::fns::mask::Mask::deserialize(&self, _metadata: &

pub fn vortex_array::scalar_fn::fns::mask::Mask::execute(&self, _options: &Self::Options, args: &dyn vortex_array::scalar_fn::ExecutionArgs, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::ArrayRef>

pub fn vortex_array::scalar_fn::fns::mask::Mask::fmt_sql(&self, _options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
pub fn vortex_array::scalar_fn::fns::mask::Mask::fmt_sql(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

pub fn vortex_array::scalar_fn::fns::mask::Mask::id(&self) -> vortex_array::scalar_fn::ScalarFnId

Expand Down Expand Up @@ -18296,7 +18296,7 @@ pub fn vortex_array::scalar_fn::fns::merge::Merge::deserialize(&self, _metadata:

pub fn vortex_array::scalar_fn::fns::merge::Merge::execute(&self, options: &Self::Options, args: &dyn vortex_array::scalar_fn::ExecutionArgs, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::ArrayRef>

pub fn vortex_array::scalar_fn::fns::merge::Merge::fmt_sql(&self, _options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
pub fn vortex_array::scalar_fn::fns::merge::Merge::fmt_sql(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

pub fn vortex_array::scalar_fn::fns::merge::Merge::id(&self) -> vortex_array::scalar_fn::ScalarFnId

Expand Down Expand Up @@ -18334,7 +18334,7 @@ pub fn vortex_array::scalar_fn::fns::not::Not::deserialize(&self, _metadata: &[u

pub fn vortex_array::scalar_fn::fns::not::Not::execute(&self, _data: &Self::Options, args: &dyn vortex_array::scalar_fn::ExecutionArgs, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::ArrayRef>

pub fn vortex_array::scalar_fn::fns::not::Not::fmt_sql(&self, _options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
pub fn vortex_array::scalar_fn::fns::not::Not::fmt_sql(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

pub fn vortex_array::scalar_fn::fns::not::Not::id(&self) -> vortex_array::scalar_fn::ScalarFnId

Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ mod tests {
"(($.col1 < $.col2) or ($.col1 != $.col2))"
);

assert_eq!(not(col1).to_string(), "not($.col1)");
assert_eq!(not(col1).to_string(), "vortex.not($.col1)");

assert_eq!(
select(vec![FieldName::from("col1")], root()).to_string(),
Expand Down
17 changes: 1 addition & 16 deletions vortex-array/src/scalar_fn/fns/fill_null/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

mod kernel;

use std::fmt::Formatter;

pub use kernel::*;
use vortex_error::VortexResult;
use vortex_error::vortex_bail;
Expand Down Expand Up @@ -66,19 +64,6 @@ impl ScalarFnVTable for FillNull {
}
}

fn fmt_sql(
&self,
_options: &Self::Options,
expr: &Expression,
f: &mut Formatter<'_>,
) -> std::fmt::Result {
write!(f, "fill_null(")?;
expr.child(0).fmt_sql(f)?;
write!(f, ", ")?;
expr.child(1).fmt_sql(f)?;
write!(f, ")")
}

fn return_dtype(&self, _options: &Self::Options, arg_dtypes: &[DType]) -> VortexResult<DType> {
vortex_ensure!(
arg_dtypes[0].eq_ignore_nullability(&arg_dtypes[1]),
Expand Down Expand Up @@ -265,6 +250,6 @@ mod tests {
#[test]
fn test_display() {
let expr = fill_null(get_item("value", root()), lit(0i32));
assert_eq!(expr.to_string(), "fill_null($.value, 0i32)");
assert_eq!(expr.to_string(), "vortex.fill_null($.value, 0i32)");
}
}
17 changes: 2 additions & 15 deletions vortex-array/src/scalar_fn/fns/is_null.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use std::fmt::Formatter;

use vortex_error::VortexResult;
use vortex_session::VortexSession;

Expand Down Expand Up @@ -60,17 +58,6 @@ impl ScalarFnVTable for IsNull {
}
}

fn fmt_sql(
&self,
_options: &Self::Options,
expr: &Expression,
f: &mut Formatter<'_>,
) -> std::fmt::Result {
write!(f, "is_null(")?;
expr.child(0).fmt_sql(f)?;
write!(f, ")")
}

fn return_dtype(&self, _options: &Self::Options, _arg_dtypes: &[DType]) -> VortexResult<DType> {
Ok(DType::Bool(Nullability::NonNullable))
}
Expand Down Expand Up @@ -240,10 +227,10 @@ mod tests {
#[test]
fn test_display() {
let expr = is_null(get_item("name", root()));
assert_eq!(expr.to_string(), "is_null($.name)");
assert_eq!(expr.to_string(), "vortex.is_null($.name)");

let expr2 = is_null(root());
assert_eq!(expr2.to_string(), "is_null($)");
assert_eq!(expr2.to_string(), "vortex.is_null($)");
}

#[test]
Expand Down
18 changes: 2 additions & 16 deletions vortex-array/src/scalar_fn/fns/list_contains/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

mod kernel;

use std::fmt::Formatter;
use std::ops::BitOr;

use arrow_buffer::bit_iterator::BitIndexIterator;
Expand Down Expand Up @@ -89,19 +88,6 @@ impl ScalarFnVTable for ListContains {
),
}
}
fn fmt_sql(
&self,
_options: &Self::Options,
expr: &Expression,
f: &mut Formatter<'_>,
) -> std::fmt::Result {
write!(f, "contains(")?;
expr.child(0).fmt_sql(f)?;
write!(f, ", ")?;
expr.child(1).fmt_sql(f)?;
write!(f, ")")
}

fn return_dtype(&self, _options: &Self::Options, arg_dtypes: &[DType]) -> VortexResult<DType> {
let list_dtype = &arg_dtypes[0];
let needle_dtype = &arg_dtypes[1];
Expand Down Expand Up @@ -655,10 +641,10 @@ mod tests {
#[test]
pub fn test_display() {
let expr = list_contains(get_item("tags", root()), lit("urgent"));
assert_eq!(expr.to_string(), "contains($.tags, \"urgent\")");
assert_eq!(expr.to_string(), "vortex.list.contains($.tags, \"urgent\")");

let expr2 = list_contains(root(), lit(42));
assert_eq!(expr2.to_string(), "contains($, 42i32)");
assert_eq!(expr2.to_string(), "vortex.list.contains($, 42i32)");
}

#[test]
Expand Down
14 changes: 0 additions & 14 deletions vortex-array/src/scalar_fn/fns/mask/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-FileCopyrightText: Copyright the Vortex contributors

mod kernel;
use std::fmt::Formatter;

pub use kernel::*;
use vortex_error::VortexExpect;
Expand Down Expand Up @@ -73,19 +72,6 @@ impl ScalarFnVTable for Mask {
}
}

fn fmt_sql(
&self,
_options: &Self::Options,
expr: &Expression,
f: &mut Formatter<'_>,
) -> std::fmt::Result {
write!(f, "mask(")?;
expr.child(0).fmt_sql(f)?;
write!(f, ", ")?;
expr.child(1).fmt_sql(f)?;
write!(f, ")")
}

fn return_dtype(&self, _options: &Self::Options, arg_dtypes: &[DType]) -> VortexResult<DType> {
vortex_ensure!(
arg_dtypes[1] == DType::Bool(Nullability::NonNullable),
Expand Down
23 changes: 5 additions & 18 deletions vortex-array/src/scalar_fn/fns/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,6 @@ impl ScalarFnVTable for Merge {
ChildName::from(Arc::from(format!("{}", child_idx)))
}

fn fmt_sql(
&self,
_options: &Self::Options,
expr: &Expression,
f: &mut Formatter<'_>,
) -> std::fmt::Result {
write!(f, "merge(")?;
for (i, child) in expr.children().iter().enumerate() {
child.fmt_sql(f)?;
if i + 1 < expr.children().len() {
write!(f, ", ")?;
}
}
write!(f, ")")
}

fn return_dtype(&self, options: &Self::Options, arg_dtypes: &[DType]) -> VortexResult<DType> {
let mut field_names = Vec::new();
let mut arrays = Vec::new();
Expand Down Expand Up @@ -540,10 +524,13 @@ mod tests {
#[test]
pub fn test_display() {
let expr = merge([get_item("struct1", root()), get_item("struct2", root())]);
assert_eq!(expr.to_string(), "merge($.struct1, $.struct2)");
assert_eq!(
expr.to_string(),
"vortex.merge($.struct1, $.struct2, opts=Error)"
);

let expr2 = merge(vec![get_item("a", root())]);
assert_eq!(expr2.to_string(), "merge($.a)");
assert_eq!(expr2.to_string(), "vortex.merge($.a, opts=Error)");
}

#[test]
Expand Down
18 changes: 2 additions & 16 deletions vortex-array/src/scalar_fn/fns/not/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

mod kernel;

use std::fmt::Formatter;

pub use kernel::*;
use vortex_error::VortexResult;
use vortex_error::vortex_bail;
Expand All @@ -19,7 +17,6 @@ use crate::arrays::ConstantArray;
use crate::arrays::bool::BoolArrayExt;
use crate::builtins::ArrayBuiltins;
use crate::dtype::DType;
use crate::expr::Expression;
use crate::scalar::Scalar;
use crate::scalar_fn::Arity;
use crate::scalar_fn::ChildName;
Expand Down Expand Up @@ -62,17 +59,6 @@ impl ScalarFnVTable for Not {
}
}

fn fmt_sql(
&self,
_options: &Self::Options,
expr: &Expression,
f: &mut Formatter<'_>,
) -> std::fmt::Result {
write!(f, "not(")?;
expr.child(0).fmt_sql(f)?;
write!(f, ")")
}

fn return_dtype(&self, _options: &Self::Options, arg_dtypes: &[DType]) -> VortexResult<DType> {
let child_dtype = &arg_dtypes[0];
if !matches!(child_dtype, DType::Bool(_)) {
Expand Down Expand Up @@ -155,8 +141,8 @@ mod tests {
let a = not(get_item("a", root()));
let b = get_item("a", not(root()));
assert_ne!(a.to_string(), b.to_string());
assert_eq!(a.to_string(), "not($.a)");
assert_eq!(b.to_string(), "not($).a");
assert_eq!(a.to_string(), "vortex.not($.a)");
assert_eq!(b.to_string(), "vortex.not($).a");
}

#[test]
Expand Down
17 changes: 16 additions & 1 deletion vortex-array/src/scalar_fn/vtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::dtype::DType;
use crate::expr::Expression;
use crate::expr::StatsCatalog;
use crate::expr::stats::Stat;
use crate::expr::traversal::Node;
use crate::scalar_fn::ScalarFn;
use crate::scalar_fn::ScalarFnId;
use crate::scalar_fn::ScalarFnRef;
Expand Down Expand Up @@ -77,7 +78,21 @@ pub trait ScalarFnVTable: 'static + Sized + Clone + Send + Sync {
options: &Self::Options,
expr: &Expression,
f: &mut Formatter<'_>,
) -> fmt::Result;
) -> fmt::Result {
write!(f, "{}(", self.id())?;
let nchildren = expr.children_count();
for (i, child) in expr.children().iter().enumerate() {
child.fmt_sql(f)?;
if i + 1 < nchildren {
write!(f, ", ")?;
}
}
let opts = format!("{}", options);
if !opts.is_empty() {
write!(f, ", opts={}", opts)?;
}
write!(f, ")")
}

/// Coerce the arguments of this function.
///
Expand Down
Loading
Loading