Skip to content

TPC-DS Q7 — Promotion Analysis

TPC-DS benchmark · all TPC-DS queries

Reports promotional impact on store sales for specific customer demographics

Representative SQL

Rendered for DataFusion with default parameters.

SELECT
i_item_id,
AVG(ss_quantity) AS agg1,
AVG(ss_list_price) AS agg2,
AVG(ss_coupon_amt) AS agg3,
AVG(ss_sales_price) AS agg4
FROM store_sales, customer_demographics, date_dim, item, promotion
WHERE
ss_sold_date_sk = d_date_sk
AND ss_item_sk = i_item_sk
AND ss_cdemo_sk = cd_demo_sk
AND ss_promo_sk = p_promo_sk
AND cd_gender = 'F'
AND cd_marital_status = 'W'
AND cd_education_status = 'Primary'
AND (
p_channel_email = 'N' OR p_channel_event = 'N'
)
AND d_year = 1998
GROUP BY
i_item_id
ORDER BY
i_item_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['7'])

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

print(bench.get_query(7, 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', '7', family="expression").source) # or family="pandas"

Source

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