Skip to content

TPC-DS-OBT Q36

TPC-DS-OBT benchmark · all TPC-DS-OBT queries

Representative SQL

Rendered for DataFusion with default parameters.

SELECT
CAST(SUM(net_profit) AS DOUBLE PRECISION) / SUM(ext_sales_price) AS gross_margin,
item_i_category,
item_i_class,
GROUPING(item_i_category) + GROUPING(item_i_class) AS lochierarchy,
RANK() OVER (
PARTITION BY GROUPING(item_i_category) + GROUPING(item_i_class), CASE WHEN GROUPING(item_i_class) = 0 THEN item_i_category END
ORDER BY CAST(SUM(net_profit) AS DOUBLE PRECISION) / SUM(ext_sales_price) ASC
) AS rank_within_parent
FROM tpcds_sales_returns_obt AS obt
WHERE
(
sold_date_d_year = 1998
AND sold_date_d_date_sk = sold_date_sk
AND item_i_item_sk = item_sk
AND store_s_store_sk = store_sk
AND store_s_state IN ('0', '0', '0', '0', '0', '0', '0', '0')
)
AND channel = 'store'
GROUP BY
ROLLUP (
item_i_category,
item_i_class
)
ORDER BY
lochierarchy DESC,
CASE WHEN lochierarchy = 0 THEN item_i_category END,
rank_within_parent
LIMIT 100

Representative DataFrame

No DataFrame implementation is registered for this query.

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

Source

Query text: benchbox/core/tpcds_obt/queries.py