TPC-DS-OBT Q49
TPC-DS-OBT benchmark · all TPC-DS-OBT queries
Representative SQL
Rendered for DataFusion with default parameters.
SELECT channel, item, return_ratio, return_rank, currency_rankFROM ( SELECT 'web' AS channel, web.item, web.return_ratio, web.return_rank, web.currency_rank FROM ( SELECT item, return_ratio, currency_ratio, RANK() OVER (ORDER BY return_ratio) AS return_rank, RANK() OVER (ORDER BY currency_ratio) AS currency_rank FROM ( SELECT item_sk AS item, CAST(SUM(COALESCE(return_quantity, 0)) AS DECIMAL(15, 4)) / NULLIF(CAST(SUM(COALESCE(quantity, 0)) AS DECIMAL(15, 4)), 0) AS return_ratio, CAST(SUM(COALESCE(return_amount, 0)) AS DECIMAL(15, 4)) / NULLIF(CAST(SUM(COALESCE(net_paid, 0)) AS DECIMAL(15, 4)), 0) AS currency_ratio FROM tpcds_sales_returns_obt WHERE channel = 'web' AND return_amount > 10000 AND net_profit > 1 AND net_paid > 0 AND quantity > 0 AND sold_date_d_year = 1998 AND sold_date_d_moy = 11 GROUP BY item_sk ) AS in_web ) AS web WHERE web.return_rank <= 10 OR web.currency_rank <= 10 UNION SELECT 'catalog' AS channel, catalog.item, catalog.return_ratio, catalog.return_rank, catalog.currency_rank FROM ( SELECT item, return_ratio, currency_ratio, RANK() OVER (ORDER BY return_ratio) AS return_rank, RANK() OVER (ORDER BY currency_ratio) AS currency_rank FROM ( SELECT item_sk AS item, CAST(SUM(COALESCE(return_quantity, 0)) AS DECIMAL(15, 4)) / NULLIF(CAST(SUM(COALESCE(quantity, 0)) AS DECIMAL(15, 4)), 0) AS return_ratio, CAST(SUM(COALESCE(return_amount, 0)) AS DECIMAL(15, 4)) / NULLIF(CAST(SUM(COALESCE(net_paid, 0)) AS DECIMAL(15, 4)), 0) AS currency_ratio FROM tpcds_sales_returns_obt WHERE channel = 'catalog' AND return_amount > 10000 AND net_profit > 1 AND net_paid > 0 AND quantity > 0 AND sold_date_d_year = 1998 AND sold_date_d_moy = 11 GROUP BY item_sk ) AS in_cat ) AS catalog WHERE catalog.return_rank <= 10 OR catalog.currency_rank <= 10 UNION SELECT 'store' AS channel, store.item, store.return_ratio, store.return_rank, store.currency_rank FROM ( SELECT item, return_ratio, currency_ratio, RANK() OVER (ORDER BY return_ratio) AS return_rank, RANK() OVER (ORDER BY currency_ratio) AS currency_rank FROM ( SELECT item_sk AS item, CAST(SUM(COALESCE(return_quantity, 0)) AS DECIMAL(15, 4)) / NULLIF(CAST(SUM(COALESCE(quantity, 0)) AS DECIMAL(15, 4)), 0) AS return_ratio, CAST(SUM(COALESCE(return_amount, 0)) AS DECIMAL(15, 4)) / NULLIF(CAST(SUM(COALESCE(net_paid, 0)) AS DECIMAL(15, 4)), 0) AS currency_ratio FROM tpcds_sales_returns_obt WHERE channel = 'store' AND return_amount > 10000 AND net_profit > 1 AND net_paid > 0 AND quantity > 0 AND sold_date_d_year = 1998 AND sold_date_d_moy = 11 GROUP BY item_sk ) AS in_store ) AS store WHERE store.return_rank <= 10 OR store.currency_rank <= 10) AS combinedORDER BY 1, 4, 5, 2LIMIT 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['49'])Source
Query text: benchbox/core/tpcds_obt/queries.py