Skip to content

The universal DataFrame API

Your PySpark code.
Your database.

Run familiar DataFrame transformations directly on your database. No Spark cluster required.

Your DataFrame · Python
from sqlframe.duckdb import functions as F

totals = (
    session.table("orders")
    .groupBy("country")
    .agg(F.sum("revenue").alias("total_revenue"))
)
↓ SQL · totals.sql(optimize=True)
SELECT
  `orders`.`country` AS `country`,
  SUM(`orders`.`revenue`) AS `total_revenue`
FROM `orders` AS `orders`
GROUP BY
  `orders`.`country`

01 / Familiar

Keep your DataFrame API

Use familiar PySpark transformations, joins, and window functions.

02 / Direct

Use your database

Execute transformations where your data already lives.

03 / Transparent

See the SQL

Inspect and share the SQL behind your DataFrame code.

Start small. Run locally.

DuckDB quickstart →

pip install "sqlframe[duckdb]"
Python · No cloud account needed
from sqlframe.duckdb import DuckDBSession

session = DuckDBSession()
df = session.createDataFrame(
    [("US", 120), ("UK", 80), ("US", 30)],
    ["country", "revenue"],
)
df.groupBy("country").sum("revenue").orderBy("country").show()
Result
country sum(revenue)
UK 80
US 150

Three rows of data. One familiar API. Executed by DuckDB.

Bring an existing PySpark pipeline →

Keep your imports using SQLFrame activation.

Just need the SQL? →

Generate queries with a standalone session.

Make SQLFrame your own →

Configure dialects, generated SQL, and session behavior.

Explore more examples →

Build transformations with joins and window functions.