Read Primitives — Array Unnest
Read Primitives benchmark · all Read Primitives queries
Unnest/explode array back to rows
Representative SQL
Rendered for DataFusion with default parameters.
WITH supplier_parts AS ( SELECT ps_suppkey, ARRAY_AGG(ps_partkey) AS parts FROM partsupp WHERE ps_suppkey <= 10 GROUP BY ps_suppkey)SELECT ps_suppkey, UNNEST(parts) AS part_keyFROM supplier_partsRepresentative DataFrame
Expression family (Polars, PySpark, DataFusion), default parameters.
def array_unnest_expression_impl(ctx: DataFrameContext) -> Any: partsupp = ctx.get_table("partsupp") col = ctx.col lit = ctx.lit
filtered = partsupp.filter(col("ps_suppkey") <= lit(10)) supplier_parts = filtered.group_by("ps_suppkey").agg(col("ps_partkey").list().alias("parts"))
return supplier_parts.explode("parts").rename({"parts": "part_key"})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['array_unnest'])For the DataFrame form:
from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('read_primitives', 'array_unnest', family="expression").source) # or family="pandas"Source
Query text: benchbox/core/read_primitives/queries.py