Read Primitives — Nested Aggregation
Read Primitives benchmark · all Read Primitives queries
Nested aggregation requiring CTE materialization
Representative SQL
Rendered for DataFusion with default parameters.
WITH order_totals AS ( SELECT o_custkey, SUM(o_totalprice) AS customer_total FROM orders GROUP BY o_custkey)SELECT AVG(customer_total) AS avg_customer_spendingFROM order_totalsRepresentative DataFrame
Expression family (Polars, PySpark, DataFusion), default parameters.
def aggregation_materialize_expression_impl(ctx: DataFrameContext) -> Any: totals = ctx.get_table("orders").group_by("o_custkey").agg(ctx.col("o_totalprice").sum().alias("customer_total")) return totals.select(ctx.col("customer_total").mean().alias("avg_customer_spending"))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['aggregation_materialize'])For the DataFrame form:
from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('read_primitives', 'aggregation_materialize', family="expression").source) # or family="pandas"Source
Query text: benchbox/core/read_primitives/queries.py