fv_value_datafusion/lib.rs
1//! The [`fv_value`] expression dialect as DataFusion expressions.
2//!
3//! [`Translator`] turns a compiled [`fv_value::Expr`] into a `datafusion::logical_expr::Expr`
4//! wherever the dialect's semantics can be reproduced exactly — so the planner can push it down to
5//! a source, vectorize it and reorder it — and leaves the rest to a per-row fallback
6//! ([`EvalUdf`]). The contract's conformance vectors, evaluated both natively and through
7//! DataFusion, are the test that the two never disagree.
8//!
9//! ```
10//! use std::sync::Arc;
11//! use datafusion::arrow::datatypes::{DataType, Field, Schema};
12//! use fv_value_datafusion::Translator;
13//!
14//! let schema = Arc::new(Schema::new(vec![
15//! Field::new("status", DataType::Utf8, true),
16//! Field::new("speed", DataType::Float64, true),
17//! ]));
18//! let expr = fv_value::compile("status == 'ACTIVE' && speed * 1.852 > 100").unwrap();
19//! let t = Translator::new(schema).translate(&expr).unwrap();
20//! assert!(t.exact);
21//! // `t.expr` is a DataFusion `Expr` you can hand to `DataFrame::filter`.
22//! ```
23
24/// Every Rust code block in the README is compiled as a doctest.
25#[cfg(doctest)]
26#[doc = include_str!("../README.md")]
27pub struct ReadmeDoctests;
28
29pub mod convert;
30mod geo;
31pub mod translate;
32pub mod udf;
33
34pub use convert::{cell_to_value, data_type_for, field_has_value_form, has_value_form, values_to_array, Cells, Kind};
35pub use translate::{Options, Translation, Translator, Unsupported};
36pub use udf::{all_finite, fallback, ErrorUdf, EvalUdf, FiniteUdf};