Skip to content

Read Primitives — Array Aggregation

Read Primitives benchmark · all Read Primitives queries

Aggregate part keys into arrays per supplier

Representative SQL

Rendered for DataFusion with default parameters.

SELECT
ps_suppkey,
ARRAY_AGG(ps_partkey ORDER BY ps_partkey) AS supplied_parts,
COUNT(*) AS part_count
FROM partsupp
GROUP BY
ps_suppkey
HAVING
COUNT(*) <= 100
ORDER BY
ps_suppkey
LIMIT 100

Representative DataFrame

Expression family (Polars, PySpark, DataFusion), default parameters.

def array_agg_simple_expression_impl(ctx: DataFrameContext) -> Any:
col = ctx.col
return (
ctx.get_table("partsupp")
.group_by("ps_suppkey")
.agg(
col("ps_partkey").sort_by("ps_partkey").alias("supplied_parts"),
col("ps_partkey").count().alias("part_count"),
)
.filter(col("part_count") <= 100)
.sort("ps_suppkey")
.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 factor
queries = bench.get_queries(dialect="datafusion") # your platform's dialect; drop dialect= for native SQL
print(queries['array_agg_simple'])

For the DataFrame form:

from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('read_primitives', 'array_agg_simple', family="expression").source) # or family="pandas"

Source

Query text: benchbox/core/read_primitives/queries.py