Read Primitives — Array Length
Read Primitives benchmark · all Read Primitives queries
Get array length/cardinality
Representative SQL
Rendered in the benchmark’s native SQL with default parameters (no dialect translation available).
WITH supplier_parts AS ( SELECT ps_suppkey, ARRAY_AGG(ps_partkey) AS parts FROM partsupp GROUP BY ps_suppkey)SELECT ps_suppkey, CARDINALITY(parts) AS num_partsFROM supplier_partsORDER BY num_parts DESC, ps_suppkeyLIMIT 100Representative DataFrame
Expression family (Polars, PySpark, DataFusion), default parameters.
def array_length_expression_impl(ctx: DataFrameContext) -> Any: col = ctx.col
return ( _expr_grouped_list(ctx, "partsupp", "ps_suppkey", "ps_partkey", "parts") .with_columns(col("parts").list.len().alias("num_parts")) .select("ps_suppkey", "num_parts") .sort(["num_parts", "ps_suppkey"], descending=[True, False]) .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['array_length'])For the DataFrame form:
from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('read_primitives', 'array_length', family="expression").source) # or family="pandas"Source
Query text: benchbox/core/read_primitives/queries.py