Skip to content

Commit

Permalink
isnan was moved to datafusion-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmmease committed Feb 20, 2024
1 parent 58a80aa commit 5251dac
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 43 deletions.
76 changes: 51 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 9 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,26 @@ prost = { version = "0.12.1" }
prost-types = { version = "0.12.1" }
object_store = { version= "0.9.0" }

# Post 35.0.0
[workspace.dependencies.datafusion]
git = "https://github.com/apache/arrow-datafusion.git"
ref = "441a4356b889edde0802ec1b394f1f10c18283c3"
version = "36.0.0"

[workspace.dependencies.datafusion-common]
git = "https://github.com/apache/arrow-datafusion.git"
default_features = false
ref = "441a4356b889edde0802ec1b394f1f10c18283c3"
version = "36.0.0"

[workspace.dependencies.datafusion-expr]
git = "https://github.com/apache/arrow-datafusion.git"
ref = "441a4356b889edde0802ec1b394f1f10c18283c3"
version = "36.0.0"

[workspace.dependencies.datafusion-proto]
git = "https://github.com/apache/arrow-datafusion.git"
ref = "441a4356b889edde0802ec1b394f1f10c18283c3"
version = "36.0.0"

[workspace.dependencies.datafusion-physical-expr]
git = "https://github.com/apache/arrow-datafusion.git"
ref = "441a4356b889edde0802ec1b394f1f10c18283c3"
version = "36.0.0"

[workspace.dependencies.datafusion-optimizer]
git = "https://github.com/apache/arrow-datafusion.git"
ref = "441a4356b889edde0802ec1b394f1f10c18283c3"
version = "36.0.0"

[workspace.dependencies.datafusion-functions]
version = "36.0.0"

[profile.release]
## Tell `rustc` to use highest performance optimization and perform Link Time Optimization
Expand Down
3 changes: 3 additions & 0 deletions vegafusion-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ workspace = true
[dependencies.datafusion-optimizer]
workspace = true

[dependencies.datafusion-functions]
workspace = true

[dependencies.tokio]
workspace = true
features = [ "macros", "rt-multi-thread", "fs",]
Expand Down
22 changes: 18 additions & 4 deletions vegafusion-runtime/src/expression/compiler/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::expression::compiler::builtin_functions::type_checking::isvalid::is_v
use crate::expression::compiler::compile;
use crate::expression::compiler::config::CompilationConfig;
use datafusion_expr::{expr, BuiltinScalarFunction, Expr, ScalarFunctionDefinition, ScalarUDF};
use datafusion_functions::expr_fn::isnan;
use std::collections::HashMap;
use std::ops::Deref;
use std::str::FromStr;
Expand Down Expand Up @@ -48,6 +49,7 @@ use crate::task_graph::timezone::RuntimeTzConfig;

pub type MacroFn = Arc<dyn Fn(&[Expression]) -> Result<Expression> + Send + Sync>;
pub type TransformFn = Arc<dyn Fn(&[Expr], &DFSchema) -> Result<Expr> + Send + Sync>;
pub type ScalarTransformFn = Arc<dyn Fn(Expr) -> Expr + Send + Sync>;
pub type TzTransformFn =
Arc<dyn Fn(&RuntimeTzConfig, &[Expr], &DFSchema) -> Result<Expr> + Send + Sync>;
pub type DataFn = Arc<
Expand All @@ -64,6 +66,9 @@ pub enum VegaFusionCallable {
/// A function that operates on the compiled arguments and produces a new expression.
Transform(TransformFn),

/// An infallible function that operates on a single compiled argument
UnaryTransform(ScalarTransformFn),

/// A function that uses the local timezone to operate on the compiled arguments and
/// produces a new expression.
LocalTransform(TzTransformFn),
Expand Down Expand Up @@ -183,6 +188,18 @@ pub fn compile_call(
let args = compile_scalar_arguments(node, config, schema, &None)?;
callable(&args, schema)
}
VegaFusionCallable::UnaryTransform(callable) => {
let mut args = compile_scalar_arguments(node, config, schema, &None)?;
if args.len() != 1 {
Err(VegaFusionError::internal(format!(
"The {} function requires 1 argument. Received {}",
&node.callee,
args.len()
)))
} else {
Ok(callable(args.pop().unwrap()))
}
}
VegaFusionCallable::LocalTransform(callable) => {
let args = compile_scalar_arguments(node, config, schema, &None)?;
let tz_config = config
Expand Down Expand Up @@ -235,10 +252,7 @@ pub fn default_callables() -> HashMap<String, VegaFusionCallable> {

callables.insert(
"isNaN".to_string(),
VegaFusionCallable::BuiltinScalarFunction {
function: BuiltinScalarFunction::Isnan,
cast: Some(DataType::Float64),
},
VegaFusionCallable::UnaryTransform(Arc::new(isnan)),
);

callables.insert(
Expand Down

0 comments on commit 5251dac

Please sign in to comment.