TPC-DS-OBT Q1 — obt_row_count
TPC-DS-OBT benchmark · all TPC-DS-OBT queries
Total row count for OBT table
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.store_sk AS ctr_store_sk, SUM(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 = 1998 ) AND channel = 'store' GROUP BY obt.returning_customer_c_customer_sk, obt.store_sk)SELECT bill_customer_c_customer_idFROM tpcds_sales_returns_obt AS obtCROSS JOIN customer_total_return AS ctr1WHERE ( ctr1.ctr_total_return > ( SELECT AVG(ctr_total_return) * 1.2 FROM customer_total_return AS ctr2 WHERE ctr1.ctr_store_sk = ctr2.ctr_store_sk ) AND store_s_store_sk = ctr1.ctr_store_sk AND store_s_state = '0' AND ctr1.ctr_customer_sk = bill_customer_c_customer_sk ) AND channel = 'store'ORDER BY bill_customer_c_customer_idLIMIT 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['1'])For the DataFrame form:
from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('tpcds_obt', '1', family="expression").source) # or family="pandas"Source
Query text: benchbox/core/tpcds_obt/queries.py