Skip to main content

robin_sparkless/
lib.rs

1//! Robin Sparkless - A Rust DataFrame library with PySpark-like API
2//!
3//! This library provides a PySpark-compatible API built on top of Polars,
4//! offering high-performance data processing in pure Rust.
5//!
6//! # Getting started and embedding
7//!
8//! For application code and embedding, use the [prelude]: `use robin_sparkless::prelude::*`.
9//! For a minimal FFI surface, use [prelude::embed].
10//!
11//! # Panics and errors
12//!
13//! Some functions panic when used with invalid or empty inputs (e.g. calling
14//! `when(cond).otherwise(val)` without `.then()`, or passing no columns to
15//! `format_string`, `elt`, `concat`, `coalesce`, or `named_struct` in Rust).
16//! In Rust, `create_map` and `array` return `Result` for empty input instead of
17//! panicking. From Python, empty columns for `coalesce`, `format_string`,
18//! `printf`, and `named_struct` raise `ValueError`. See the documentation for
19//! each function for details.
20//!
21//! # API stability
22//!
23//! While the crate is in the 0.x series, we follow [semver](https://semver.org/) but may introduce
24//! breaking changes in minor releases (e.g. 0.1 → 0.2) until 1.0. For behavioral caveats and
25//! intentional differences from PySpark, see the [repository documentation](https://github.com/eddiethedean/robin-sparkless/blob/main/docs/PYSPARK_DIFFERENCES.md).
26
27#![allow(clippy::collapsible_if)]
28#![allow(clippy::let_and_return)]
29
30pub mod config;
31pub mod dataframe;
32pub mod error;
33pub mod functions;
34pub mod plan;
35pub mod prelude;
36pub mod schema;
37pub(crate) mod schema_conv;
38pub mod session;
39pub mod traits;
40
41pub use robin_sparkless_expr::column;
42pub use robin_sparkless_expr::expression;
43pub use robin_sparkless_expr::type_coercion;
44pub use robin_sparkless_expr::{Column, RustUdf, UdfRegistry};
45
46pub(crate) use robin_sparkless_expr::udfs;
47
48pub(crate) use robin_sparkless_core::date_utils;
49
50/// Re-export the underlying expression and literal types so downstream
51/// bindings can depend on `robin_sparkless::Expr` / `LiteralValue`
52/// instead of importing Polars directly.
53pub type Expr = polars::prelude::Expr;
54pub type LiteralValue = polars::prelude::LiteralValue;
55
56#[cfg(feature = "sql")]
57pub mod sql;
58
59#[cfg(feature = "delta")]
60pub mod delta;
61
62pub use config::SparklessConfig;
63pub use dataframe::{
64    CubeRollupData, DataFrame, GroupedData, JoinType, PivotedGroupedData, SaveMode, WriteFormat,
65    WriteMode,
66};
67pub use error::EngineError;
68pub use functions::{SortOrder, *};
69pub use schema::{DataType, StructField, StructType, schema_from_json};
70pub use session::{DataFrameReader, SparkSession, SparkSessionBuilder};
71pub use traits::{FromRobinDf, IntoRobinDf};