Read Primitives — GROUP BY ALL Complex
Read Primitives benchmark · all Read Primitives queries
GROUP BY ALL with multiple non-aggregate expressions
Representative SQL
Rendered for DataFusion with default parameters.
SELECT DATE_TRUNC('MONTH', o_orderdate) AS order_month, o_orderpriority, COUNT(o_orderkey) AS order_count, SUM(o_totalprice) AS monthly_revenueFROM ordersWHERE o_orderdate >= CAST('1995-01-01' AS DATE)GROUP BY DATE_TRUNC('MONTH', o_orderdate), o_orderpriorityORDER BY order_month, o_orderpriorityRepresentative DataFrame
Expression family (Polars, PySpark, DataFusion), default parameters.
def groupby_all_complex_expression_impl(ctx: DataFrameContext) -> Any: orders = ctx.get_table("orders") col = ctx.col lit = ctx.lit
filtered = orders.filter(col("o_orderdate") >= lit(date(1995, 1, 1))) return ( filtered.with_columns(col("o_orderdate").dt.truncate("1mo").alias("order_month")) .group_by("order_month", "o_orderpriority") .agg( col("o_orderkey").count().alias("order_count"), col("o_totalprice").sum().alias("monthly_revenue"), ) .sort(["order_month", "o_orderpriority"]) )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['groupby_all_complex'])For the DataFrame form:
from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('read_primitives', 'groupby_all_complex', family="expression").source) # or family="pandas"Source
Query text: benchbox/core/read_primitives/queries.py