Metadata-Version: 2.4
Name: datafusion-extra-functions-ffi
Version: 0.1.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Rust
Classifier: License :: OSI Approved :: Apache Software License
Requires-Dist: datafusion>=54,<55
License-File: LICENSE
Summary: datafusion-extra-functions (mode, skewness, kurtosis, max_by, min_by) for datafusion-python, via the DataFusion FFI PyCapsule protocol
License: Apache-2.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Repository, https://github.com/s5dsn-eqee/datafusion-extra-functions-ffi
Project-URL: Upstream, https://github.com/datafusion-contrib/datafusion-extra-functions

# datafusion-extra-functions-ffi

[![CI](https://github.com/s5dsn-eqee/datafusion-extra-functions-ffi/actions/workflows/ci.yml/badge.svg)](https://github.com/s5dsn-eqee/datafusion-extra-functions-ffi/actions/workflows/ci.yml)

[Apache DataFusion](https://datafusion.apache.org/) core deliberately keeps its
function library lean, so aggregates like `mode`, `skewness`, and `kurtosis`
live in the contrib
[`datafusion-extra-functions`](https://github.com/datafusion-contrib/datafusion-extra-functions)
crate — Rust-only, with no Python exposure. This package closes that gap: it
exposes the crate's aggregate UDFs to
[datafusion-python](https://datafusion.apache.org/python/) through the
`__datafusion_aggregate_udf__` PyCapsule protocol, as prebuilt wheels — no Rust
toolchain required.

## Usage

```python
from datafusion import SessionContext, col, udaf
import datafusion_extra_functions_ffi as ffi

ffi.list_functions()
# ['mode', 'max_by', 'min_by', 'kurtosis', 'skewness', 'kurtosis_pop']

skew = udaf(ffi.udaf_by_name("skewness"))

ctx = SessionContext()
df = ctx.from_pydict({"a": [1.0, 2.0, 2.0, 9.0]})
df.aggregate([], [skew(col("a"))]).show()
```

Or register for SQL:

```python
ctx.register_udaf(udaf(ffi.udaf_by_name("mode")))
ctx.sql("SELECT mode(a) FROM my_table").show()
```

The API is name-driven: whatever aggregates the pinned
`datafusion-extra-functions` revision provides appear in `list_functions()`
automatically.

## Version compatibility

The DataFusion FFI ABI is tied to the `datafusion` major version this package
was compiled against. The wheel pins the matching `datafusion` range
(currently `>=54,<55`), because a mismatch fails at the FFI boundary rather
than with a clean error. When a new datafusion-python major ships, this
package is rebuilt against it and re-released.

## Building from source

Requires a Rust toolchain (see `rust-version` in `Cargo.toml`).

```sh
pip install maturin
maturin develop --release
```

## License

Apache-2.0, same as the upstream crate it binds.

