Skip to content

TPC-DS Q3 — Date/Item Brand Sales

TPC-DS benchmark · all TPC-DS queries

Reports sales for items by brand for a specific month and manufacturer

Representative SQL

Rendered for DataFusion with default parameters.

SELECT
dt.d_year,
item.i_brand_id AS brand_id,
item.i_brand AS brand,
SUM(ss_ext_sales_price) AS sum_agg
FROM date_dim AS dt, store_sales, item
WHERE
dt.d_date_sk = store_sales.ss_sold_date_sk
AND store_sales.ss_item_sk = item.i_item_sk
AND item.i_manufact_id = 436
AND dt.d_moy = 12
GROUP BY
dt.d_year,
item.i_brand,
item.i_brand_id
ORDER BY
dt.d_year,
sum_agg DESC,
brand_id
LIMIT 100

Representative DataFrame

Expression family (Polars, PySpark, DataFusion), default parameters.

def impl(ctx: DataFrameContext) -> Any:
return helper(ctx, query_id, *helper_args)

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 TPCDS
bench = TPCDS(scale_factor=1.0) # your scale factor
queries = bench.get_queries(dialect="datafusion") # your platform's dialect; drop dialect= for native SQL
print(queries['3'])

Parameter substitution for this benchmark is seed-driven; pass a seed for a specific stream’s parameters:

print(bench.get_query(3, scale_factor=1.0, seed=42, dialect="datafusion"))

For the DataFrame form:

from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('tpcds', '3', family="expression").source) # or family="pandas"

Source

Query text: _sources/tpc-ds/query_templates/query3.tpl