Skip to content

TPC-DS-OBT Q30

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

Representative SQL

Rendered for DataFusion with default parameters.

WITH customer_total_return AS (
SELECT
obt.returning_customer_c_customer_sk AS ctr_customer_sk,
obt.bill_addr_ca_state AS ctr_state,
SUM(obt.return_amount) AS ctr_total_return
FROM tpcds_sales_returns_obt AS obt
WHERE
(
obt.returned_date_sk = obt.sold_date_d_date_sk
AND obt.sold_date_d_year = 1999
AND obt.returning_addr_ca_address_sk = obt.bill_addr_ca_address_sk
)
AND channel = 'web'
GROUP BY
obt.returning_customer_c_customer_sk,
obt.bill_addr_ca_state
)
SELECT
bill_customer_c_customer_id,
bill_customer_c_salutation,
bill_customer_c_first_name,
bill_customer_c_last_name,
bill_customer_c_preferred_cust_flag,
bill_customer_c_birth_day,
bill_customer_c_birth_month,
bill_customer_c_birth_year,
bill_customer_c_birth_country,
bill_customer_c_login,
bill_customer_c_email_address,
bill_customer_c_last_review_date_sk,
ctr_total_return
FROM tpcds_sales_returns_obt AS obt
CROSS JOIN customer_total_return AS ctr1
WHERE
(
ctr1.ctr_total_return > (
SELECT
AVG(ctr_total_return) * 1.2
FROM customer_total_return AS ctr2
WHERE
ctr1.ctr_state = ctr2.ctr_state
)
AND bill_addr_ca_address_sk = bill_customer_c_current_addr_sk
AND bill_addr_ca_state = '0'
AND ctr1.ctr_customer_sk = bill_customer_c_customer_sk
)
AND channel = 'web'
ORDER BY
bill_customer_c_customer_id,
bill_customer_c_salutation,
bill_customer_c_first_name,
bill_customer_c_last_name,
bill_customer_c_preferred_cust_flag,
bill_customer_c_birth_day,
bill_customer_c_birth_month,
bill_customer_c_birth_year,
bill_customer_c_birth_country,
bill_customer_c_login,
bill_customer_c_email_address,
bill_customer_c_last_review_date_sk,
ctr_total_return
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['30'])

Source

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