TPC-DS-OBT Q16 — obt_store_summary
TPC-DS-OBT benchmark · all TPC-DS-OBT queries
Store-channel sales, revenue, and profit
Representative SQL
Rendered for DataFusion with default parameters.
SELECT COUNT(DISTINCT sale_id) AS "order count", SUM(ext_ship_cost) AS "total shipping cost", SUM(net_profit) AS "total net profit"FROM tpcds_sales_returns_obt AS obtWHERE ( ship_date_d_date BETWEEN '1999-2-01' AND ( CAST('1999-2-01' AS DATE) + INTERVAL '60 DAY' ) AND obt.ship_date_sk = ship_date_d_date_sk AND obt.ship_addr_sk = ship_addr_ca_address_sk AND ship_addr_ca_state = '0' AND obt.call_center_sk = call_center_cc_call_center_sk AND call_center_cc_county IN ('0', '0', '0', '0', '0') AND EXISTS( SELECT * FROM tpcds_sales_returns_obt AS obt WHERE ( obt.sale_id = obt.sale_id AND obt.warehouse_sk <> obt.warehouse_sk ) AND channel = 'catalog' ) AND NOT EXISTS( SELECT * FROM tpcds_sales_returns_obt AS obt WHERE obt.sale_id = obt.sale_id AND obt.has_return = 'Y' AND obt.channel = 'catalog' ) ) AND channel = 'catalog'ORDER BY COUNT(DISTINCT sale_id)LIMIT 100Representative DataFrame
Expression family (Polars, PySpark, DataFusion), default parameters.
def impl(ctx: DataFrameContext) -> Any: table = ctx.get_table(OBT_TABLE) for column, op, value in spec.filters: table = table.filter(_FILTER_OPS[op](ctx.col(column), ctx.lit(value))) aggregates = [getattr(ctx.col(column), func)().alias(alias) for alias, column, func in spec.aggregations] if spec.group_keys: result = table.group_by(*spec.group_keys).agg(*aggregates) else: result = table.select(*aggregates) if spec.sort_keys: descending = list(spec.descending) if spec.descending else [False] * len(spec.sort_keys) result = result.sort(list(spec.sort_keys), descending=descending) if spec.limit: result = result.limit(spec.limit) return resultGet 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['16'])For the DataFrame form:
from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('tpcds_obt', '16', family="expression").source) # or family="pandas"Source
Query text: benchbox/core/tpcds_obt/queries.py