Skip to content

TPC-DS-OBT Q1

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

Representative SQL

Rendered for DataFusion with default parameters.

WITH customer_total_return AS (
SELECT
returning_customer_c_customer_sk AS ctr_customer_sk,
return_store_s_store_sk AS ctr_store_sk,
SUM(return_fee) AS ctr_total_return
FROM tpcds_sales_returns_obt
WHERE
channel = 'store' AND has_return = 'Y' AND return_date_d_year = 2000
GROUP BY
returning_customer_c_customer_sk,
return_store_s_store_sk
), store_attr AS (
SELECT DISTINCT
return_store_s_store_sk AS s_store_sk,
return_store_s_state AS s_state
FROM tpcds_sales_returns_obt
WHERE
channel = 'store' AND NOT return_store_s_store_sk IS NULL
), cust AS (
SELECT DISTINCT
returning_customer_c_customer_sk AS c_customer_sk,
returning_customer_c_customer_id AS c_customer_id
FROM tpcds_sales_returns_obt
WHERE
channel = 'store' AND NOT returning_customer_c_customer_sk IS NULL
)
SELECT
cust.c_customer_id
FROM customer_total_return AS ctr1
JOIN store_attr AS s
ON s.s_store_sk = ctr1.ctr_store_sk
JOIN cust
ON ctr1.ctr_customer_sk = cust.c_customer_sk
WHERE
ctr1.ctr_total_return > (
SELECT
AVG(ctr_total_return) * 1.2
FROM customer_total_return AS ctr2
WHERE
ctr1.ctr_store_sk = ctr2.ctr_store_sk
)
AND s.s_state = 'TN'
ORDER BY
cust.c_customer_id
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['1'])

Source

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