TPC-DS-OBT Q23b
TPC-DS-OBT benchmark · all TPC-DS-OBT queries
Representative SQL
Rendered for DataFusion with default parameters.
WITH frequent_ss_items AS ( SELECT SUBSTRING(obt.item_i_item_desc FROM 1 FOR 30) AS itemdesc, obt.item_i_item_sk AS item_sk, obt.sold_date_d_date AS solddate, COUNT(*) AS cnt FROM tpcds_sales_returns_obt AS obt WHERE ( obt.sold_date_sk = obt.sold_date_d_date_sk AND obt.item_sk = obt.item_i_item_sk AND obt.sold_date_d_year IN (1999, 1999 + 1, 1999 + 2, 1999 + 3) ) AND channel = 'store' GROUP BY SUBSTRING(obt.item_i_item_desc FROM 1 FOR 30), obt.item_i_item_sk, obt.sold_date_d_date HAVING COUNT(*) > 4), max_store_sales AS ( SELECT MAX(csales) AS tpcds_cmax FROM ( SELECT obt.bill_customer_c_customer_sk, SUM(obt.quantity * obt.sales_price) AS csales FROM tpcds_sales_returns_obt AS obt WHERE ( obt.ship_customer_sk = obt.bill_customer_c_customer_sk AND obt.sold_date_sk = obt.sold_date_d_date_sk AND obt.sold_date_d_year IN (1999, 1999 + 1, 1999 + 2, 1999 + 3) ) AND channel = 'store' GROUP BY obt.bill_customer_c_customer_sk )), best_ss_customer AS ( SELECT obt.bill_customer_c_customer_sk, SUM(obt.quantity * obt.sales_price) AS ssales FROM tpcds_sales_returns_obt AS obt WHERE obt.ship_customer_sk = obt.bill_customer_c_customer_sk AND channel = 'store' GROUP BY obt.bill_customer_c_customer_sk HAVING SUM(obt.quantity * obt.sales_price) > ( CAST(95 AS DOUBLE PRECISION) / 100.0 ) * ( SELECT * FROM max_store_sales ))SELECT bill_customer_c_last_name, bill_customer_c_first_name, salesFROM ( SELECT obt.bill_customer_c_last_name, obt.bill_customer_c_first_name, SUM(obt.quantity * obt.list_price) AS sales FROM tpcds_sales_returns_obt AS obt WHERE ( obt.sold_date_d_year = 1999 AND obt.sold_date_d_moy = 1 AND obt.sold_date_sk = obt.sold_date_d_date_sk AND obt.item_sk IN ( SELECT item_sk FROM frequent_ss_items ) AND obt.bill_customer_sk IN ( SELECT bill_customer_c_customer_sk FROM best_ss_customer ) AND obt.bill_customer_sk = obt.bill_customer_c_customer_sk ) AND channel = 'catalog' GROUP BY obt.bill_customer_c_last_name, obt.bill_customer_c_first_name UNION ALL SELECT obt.bill_customer_c_last_name, obt.bill_customer_c_first_name, SUM(obt.quantity * obt.list_price) AS sales FROM tpcds_sales_returns_obt AS obt WHERE ( obt.sold_date_d_year = 1999 AND obt.sold_date_d_moy = 1 AND obt.sold_date_sk = obt.sold_date_d_date_sk AND obt.item_sk IN ( SELECT item_sk FROM frequent_ss_items ) AND obt.bill_customer_sk IN ( SELECT bill_customer_c_customer_sk FROM best_ss_customer ) AND obt.bill_customer_sk = obt.bill_customer_c_customer_sk ) AND channel = 'web' GROUP BY obt.bill_customer_c_last_name, obt.bill_customer_c_first_name)ORDER BY bill_customer_c_last_name, bill_customer_c_first_name, salesLIMIT 100Representative 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 factorqueries = bench.get_queries(dialect="datafusion") # your platform's dialect; drop dialect= for native SQLprint(queries['23b'])Source
Query text: benchbox/core/tpcds_obt/queries.py