Read Primitives — List Reduce
Read Primitives benchmark · all Read Primitives queries
Reduce array to single value
Representative SQL
Rendered in the benchmark’s native SQL with default parameters (no dialect translation available).
WITH quantities AS ( SELECT l_orderkey, ARRAY_AGG(l_quantity) AS qtys FROM lineitem GROUP BY l_orderkey)SELECT l_orderkey, REDUCE(qtys, 0, (acc, x) -> acc + x) AS total_qtyFROM quantitiesORDER BY l_orderkeyLIMIT 100Representative DataFrame
Expression family (Polars, PySpark, DataFusion), default parameters.
def list_reduce_expression_impl(ctx: DataFrameContext) -> Any: col = ctx.col
return ( _expr_grouped_list(ctx, "lineitem", "l_orderkey", "l_quantity", "qtys") .with_columns(col("qtys").list.sum().alias("total_qty")) .select("l_orderkey", "total_qty") .sort("l_orderkey") .limit(100) )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 ReadPrimitives
bench = ReadPrimitives(scale_factor=0.01) # your scale factorqueries = bench.get_queries(dialect="datafusion") # your platform's dialect; drop dialect= for native SQLprint(queries['list_reduce'])For the DataFrame form:
from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('read_primitives', 'list_reduce', family="expression").source) # or family="pandas"Source
Query text: benchbox/core/read_primitives/queries.py