TPC-H Q1 — Pricing Summary Report
TPC-H benchmark · all TPC-H queries
Pricing summary statistics for shipped lineitems
Representative SQL
Rendered for DataFusion with default parameters.
SELECT l_returnflag, l_linestatus, SUM(l_quantity) AS sum_qty, SUM(l_extendedprice) AS sum_base_price, SUM(l_extendedprice * ( 1 - l_discount )) AS sum_disc_price, SUM(l_extendedprice * ( 1 - l_discount ) * ( 1 + l_tax )) AS sum_charge, AVG(l_quantity) AS avg_qty, AVG(l_extendedprice) AS avg_price, AVG(l_discount) AS avg_disc, COUNT(*) AS count_orderFROM lineitemWHERE l_shipdate <= CAST('1998-12-01' AS DATE) - INTERVAL '90 DAY'GROUP BY l_returnflag, l_linestatusORDER BY l_returnflag, l_linestatusRepresentative DataFrame
Expression family (Polars, PySpark, DataFusion), default parameters.
def q1_expression_impl(ctx: DataFrameContext) -> Any: lineitem = ctx.get_table("lineitem") col = ctx.col lit = ctx.lit
params = get_tpch_parameters(1) cutoff_date = params["cutoff_date"]
return ( lineitem.filter(col("l_shipdate") <= lit(cutoff_date)) .group_by("l_returnflag", "l_linestatus") .agg( col("l_quantity").sum().alias("sum_qty"), col("l_extendedprice").sum().alias("sum_base_price"), (col("l_extendedprice") * (lit(1) - col("l_discount"))).sum().alias("sum_disc_price"), (col("l_extendedprice") * (lit(1) - col("l_discount")) * (lit(1) + col("l_tax"))).sum().alias("sum_charge"), col("l_quantity").mean().alias("avg_qty"), col("l_extendedprice").mean().alias("avg_price"), col("l_discount").mean().alias("avg_disc"), col("l_orderkey").count().alias("count_order"), ) .sort("l_returnflag", "l_linestatus") )Get the exact query for your run
The blocks above are representative. To get the precise statement a specific platform runs at a specific scale, substitute your own values:
from benchbox import TPCH
bench = TPCH(scale_factor=0.01) # your scale factorqueries = bench.get_queries(dialect="datafusion") # your platform's dialect; drop dialect= for native SQLprint(queries['1'])Parameter substitution for this benchmark is seed-driven; pass a seed for a specific stream’s parameters:
print(bench.get_query(1, scale_factor=0.01, seed=42, dialect="datafusion"))For the DataFrame form:
from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('tpch', '1', family="expression").source) # or family="pandas"Source
Query text: benchbox/_binaries/tpc-h/templates/queries/1.sql