Skip to content

TPC-DS-OBT Q17

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

Representative SQL

Rendered for DataFusion with default parameters.

SELECT
s.item_i_item_id AS i_item_id,
s.item_i_item_desc AS i_item_desc,
s.store_s_state AS s_state,
COUNT(s.quantity) AS store_sales_quantitycount,
AVG(s.quantity) AS store_sales_quantityave,
STDDEV_SAMP(s.quantity) AS store_sales_quantitystdev,
CAST(STDDEV_SAMP(s.quantity) AS DOUBLE PRECISION) / AVG(s.quantity) AS store_sales_quantitycov,
COUNT(s.return_quantity) AS store_returns_quantitycount,
AVG(s.return_quantity) AS store_returns_quantityave,
STDDEV_SAMP(s.return_quantity) AS store_returns_quantitystdev,
CAST(STDDEV_SAMP(s.return_quantity) AS DOUBLE PRECISION) / AVG(s.return_quantity) AS store_returns_quantitycov,
COUNT(c.quantity) AS catalog_sales_quantitycount,
AVG(c.quantity) AS catalog_sales_quantityave,
STDDEV_SAMP(c.quantity) AS catalog_sales_quantitystdev,
CAST(STDDEV_SAMP(c.quantity) AS DOUBLE PRECISION) / AVG(c.quantity) AS catalog_sales_quantitycov
FROM tpcds_sales_returns_obt AS s
JOIN tpcds_sales_returns_obt AS c
ON c.bill_customer_sk = s.returning_customer_c_customer_sk AND c.item_sk = s.item_sk
WHERE
s.channel = 'store'
AND s.has_return = 'Y'
AND c.channel = 'catalog'
AND s.sold_date_d_quarter_name = '1998Q1'
AND NOT s.item_i_item_sk IS NULL
AND NOT s.store_s_store_sk IS NULL
AND s.bill_customer_sk = s.returning_customer_c_customer_sk
AND s.return_date_d_quarter_name IN ('1998Q1', '1998Q2', '1998Q3')
AND c.sold_date_d_quarter_name IN ('1998Q1', '1998Q2', '1998Q3')
GROUP BY
s.item_i_item_id,
s.item_i_item_desc,
s.store_s_state
ORDER BY
s.item_i_item_id,
s.item_i_item_desc,
s.store_s_state
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['17'])

Source

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