TPC-DS-OBT Q5
TPC-DS-OBT benchmark · all TPC-DS-OBT queries
Representative SQL
Rendered for DataFusion with default parameters.
WITH ssr AS ( SELECT s_store_id, SUM(sales_price) AS sales, SUM(profit) AS profit, SUM(return_amt) AS returns, SUM(net_loss) AS profit_loss FROM ( SELECT store_s_store_id AS s_store_id, sold_date_d_date AS d_date, ext_sales_price AS sales_price, net_profit AS profit, CAST(0 AS DECIMAL(7, 2)) AS return_amt, CAST(0 AS DECIMAL(7, 2)) AS net_loss FROM tpcds_sales_returns_obt WHERE channel = 'store' AND NOT store_s_store_sk IS NULL UNION ALL SELECT return_store_s_store_id, return_date_d_date, CAST(0 AS DECIMAL(7, 2)), CAST(0 AS DECIMAL(7, 2)), return_amount, return_net_loss FROM tpcds_sales_returns_obt WHERE channel = 'store' AND has_return = 'Y' AND NOT return_store_s_store_sk IS NULL ) AS x WHERE d_date BETWEEN CAST('1998-08-04' AS DATE) AND ( CAST('1998-08-04' AS DATE) + INTERVAL '14 DAY' ) GROUP BY s_store_id), csr AS ( SELECT cp_catalog_page_id, SUM(sales_price) AS sales, SUM(profit) AS profit, SUM(return_amt) AS returns, SUM(net_loss) AS profit_loss FROM ( SELECT catalog_page_cp_catalog_page_id AS cp_catalog_page_id, sold_date_d_date AS d_date, ext_sales_price AS sales_price, net_profit AS profit, CAST(0 AS DECIMAL(7, 2)) AS return_amt, CAST(0 AS DECIMAL(7, 2)) AS net_loss FROM tpcds_sales_returns_obt WHERE channel = 'catalog' AND NOT catalog_page_cp_catalog_page_sk IS NULL UNION ALL SELECT return_catalog_page_cp_catalog_page_id, return_date_d_date, CAST(0 AS DECIMAL(7, 2)), CAST(0 AS DECIMAL(7, 2)), return_amount, return_net_loss FROM tpcds_sales_returns_obt WHERE channel = 'catalog' AND has_return = 'Y' AND NOT return_catalog_page_cp_catalog_page_sk IS NULL ) AS x WHERE d_date BETWEEN CAST('1998-08-04' AS DATE) AND ( CAST('1998-08-04' AS DATE) + INTERVAL '14 DAY' ) GROUP BY cp_catalog_page_id), wsr AS ( SELECT web_site_id, SUM(sales_price) AS sales, SUM(profit) AS profit, SUM(return_amt) AS returns, SUM(net_loss) AS profit_loss FROM ( SELECT web_site_web_site_id AS web_site_id, sold_date_d_date AS d_date, ext_sales_price AS sales_price, net_profit AS profit, CAST(0 AS DECIMAL(7, 2)) AS return_amt, CAST(0 AS DECIMAL(7, 2)) AS net_loss FROM tpcds_sales_returns_obt WHERE channel = 'web' AND NOT web_site_web_site_sk IS NULL UNION ALL SELECT web_site_web_site_id, return_date_d_date, CAST(0 AS DECIMAL(7, 2)), CAST(0 AS DECIMAL(7, 2)), return_amount, return_net_loss FROM tpcds_sales_returns_obt WHERE channel = 'web' AND has_return = 'Y' AND NOT web_site_web_site_sk IS NULL ) AS x WHERE d_date BETWEEN CAST('1998-08-04' AS DATE) AND ( CAST('1998-08-04' AS DATE) + INTERVAL '14 DAY' ) GROUP BY web_site_id)SELECT channel, id, SUM(sales) AS sales, SUM(returns) AS returns, SUM(profit) AS profitFROM ( SELECT 'store channel' AS channel, 'store' || s_store_id AS id, sales, returns, ( profit - profit_loss ) AS profit FROM ssr UNION ALL SELECT 'catalog channel', 'catalog_page' || cp_catalog_page_id, sales, returns, ( profit - profit_loss ) FROM csr UNION ALL SELECT 'web channel', 'web_site' || web_site_id, sales, returns, ( profit - profit_loss ) FROM wsr) AS xGROUP BY ROLLUP ( channel, id )ORDER BY channel, idLIMIT 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['5'])Source
Query text: benchbox/core/tpcds_obt/queries.py