Install and load
Run these commands in a Haybarn SQL session. The extension is available from the community repository.
INSTALL python_udf FROM community;
LOAD python_udf FROM community;
Using upstream DuckDB? Follow the maintainer’s installation instructions.
Usage example
SELECT py_eval('lambda x: x * 2 + 1', x) FROM range(10) t(x);
-- Aggregate UDF
SELECT py_agg('sum', x) FROM range(100) t(x);
-- Scan from Python
SELECT * FROM py_scan('lambda _: [{"a":1}, {"a":2}]');
-- Register persistent UDF
SELECT py_register('dbl', 'lambda x: x * 2');
-- Call registered UDF
SELECT py_call('dbl', 21);
-- Map values
SELECT py_map('ord', 'hello world');
Provided by alitrack. Not yet verified on Haybarn 2.0.0.
Sample data & setupAbout this extension
Execute Python code directly in SQL queries with CPython embedded in DuckDB.
Note: Extension binary name is python_udf to avoid collision with DuckDB's core python extension. The source repository remains duckdb-python.
Project overview from the community descriptor.
Documentation and resources
Project and build details
- Repository
- alitrack/duckdb-python
- License
- MIT
- Maintainers
- alitrack
- Written in
- Rust & Python
- Build source
901a7bdbc3a1- Build definition
- Community descriptor