Metadata-Version: 2.5
Name: udfx
Version: 0.1.0a2
Summary: Turn Python UDFs into native dataframe expressions
Project-URL: Homepage, https://github.com/guan404ming/udfx
Project-URL: Documentation, https://guan404ming.github.io/udfx/
Project-URL: Issues, https://github.com/guan404ming/udfx/issues
Author-email: Guan-Ming Chiu <guanmingchiu@gmail.com>
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: compiler,dataframe,datafusion,duckdb,polars,spark,udf
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Compilers
Requires-Python: <3.15,>=3.12
Provides-Extra: datafusion
Requires-Dist: datafusion>=55; extra == 'datafusion'
Requires-Dist: pyarrow>=18; extra == 'datafusion'
Provides-Extra: duckdb
Requires-Dist: duckdb>=1.4.1; extra == 'duckdb'
Requires-Dist: numpy>=2.0; extra == 'duckdb'
Requires-Dist: pyarrow>=18; extra == 'duckdb'
Provides-Extra: polars
Requires-Dist: polars>=2.0; extra == 'polars'
Provides-Extra: spark
Requires-Dist: pyarrow>=18; extra == 'spark'
Requires-Dist: pyspark>=4.1; extra == 'spark'
Provides-Extra: testing
Requires-Dist: hypothesis>=6.100; extra == 'testing'
Description-Content-Type: text/markdown

# <img src="https://raw.githubusercontent.com/guan404ming/udfx/main/docs/assets/logo.svg" alt="" height="24"> udfx

[![CI](https://github.com/guan404ming/udfx/actions/workflows/ci.yml/badge.svg)](https://github.com/guan404ming/udfx/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/udfx.svg)](https://pypi.org/project/udfx/)
[![Python](https://img.shields.io/badge/python-3.12%20%7C%203.13%20%7C%203.14-blue.svg)](pyproject.toml)
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)

**An optimizing compiler for Python UDFs**

Run your Python UDFs as native expressions in Polars, DuckDB, Apache DataFusion, and Apache Spark,
without any manual rewrites.

## Install

```sh
pip install "udfx[polars]"
```

Choose the extra for your backend: `polars`, `duckdb`, `datafusion`, or `spark`.
Apache Spark also needs Java 21.

## Quick start

```python
import polars as pl
import udfx
from udfx.types import STR


def normalize(text: str) -> str:
    return text.strip().lower()


translation = udfx.compile(normalize, {"text": STR})
assert translation.ok, translation.unsupported

frame = pl.DataFrame({"text": [" Alice ", "BOB"]})
result = frame.lazy().select(translation.expr.alias("name")).collect()
print(result["name"].to_list())
```

```text
['alice', 'bob']
```

Use `udfx.explain(normalize, {"text": STR})` to inspect native execution and fallback reasons.
Declare nullable columns with `.or_none()`. Unsupported functions return `ok == False` with a reason.

## Documentation

- [User Guide](https://guan404ming.github.io/udfx/user-guide/): installation, backends, and Python support
- [Reference API](https://guan404ming.github.io/udfx/api/): compile, types, and explain
- [Contributor Guide](https://guan404ming.github.io/udfx/contributor-guide/): development and documentation

[Contributing](CONTRIBUTING.md) · [Changelog](CHANGELOG.md) · [Apache-2.0 license](LICENSE)
