This directory contains examples demonstrating BenchBox's DataFrame benchmarking capabilities.
BenchBox supports native DataFrame benchmarking alongside traditional SQL database benchmarking. These examples show how to:
- Run TPC-H/TPC-DS queries using Polars DataFrame API
- Run queries using Pandas DataFrame API
- Compare performance across platforms
- Compare SQL vs DataFrame execution paradigms
Install the DataFrame platforms, then generate the benchmark data. The data is required before any example can execute.
pip install polars pandas
benchbox run --platform duckdb --benchmark tpch --scale 0.01 --phases load
benchbox run --platform duckdb --benchmark tpcds --scale 1 --phases loadPolars TPC-H (polars_tpch.py)
python examples/dataframe/polars_tpch.pyDemonstrates running TPC-H queries using Polars' expression API with lazy evaluation.
Pandas TPC-H (pandas_tpch.py)
python examples/dataframe/pandas_tpch.pyDemonstrates running TPC-H queries using Pandas' DataFrame API with eager evaluation.
Polars TPC-DS (polars_tpcds.py)
python examples/dataframe/polars_tpcds.pyDemonstrates running TPC-DS queries (more complex than TPC-H with 99 queries).
Cross-Platform Comparison (cross_platform_comparison.py)
python examples/dataframe/cross_platform_comparison.pyCompares query execution time across Polars and Pandas for the same queries.
SQL vs DataFrame (sql_vs_dataframe.py)
python examples/dataframe/sql_vs_dataframe.pyCompares SQL execution (DuckDB) vs DataFrame execution (Polars) for equivalent queries.
BenchBox uses a family-based architecture for DataFrame support:
result = (
df.filter(col('shipdate') <= lit(cutoff))
.group_by('status')
.agg(col('quantity').sum().alias('total_qty'))
)filtered = df[df['shipdate'] <= cutoff]
result = filtered.groupby('status').agg({'quantity': 'sum'})For production benchmarking, use the BenchBox CLI:
benchbox run --platform polars-df --benchmark tpch --scale 0.1
benchbox run --platform pandas-df --benchmark tpch --scale 0.01
benchbox compare results_polars.json results_pandas.json