Read Primitives — Array Sort
Read Primitives benchmark · all Read Primitives queries
Sort array elements
Representative SQL
Rendered for DataFusion with default parameters.
WITH part_sizes AS ( SELECT p_brand, ARRAY_AGG(p_size) AS sizes FROM part GROUP BY p_brand)SELECT p_brand, ARRAY_SORT(sizes) AS sorted_sizesFROM part_sizesORDER BY p_brandLIMIT 50Representative DataFrame
Expression family (Polars, PySpark, DataFusion), default parameters.
def array_sort_expression_impl(ctx: DataFrameContext) -> Any: col = ctx.col
return ( _expr_grouped_list(ctx, "part", "p_brand", "p_size", "sizes") .with_columns(col("sizes").list.sort().alias("sorted_sizes")) .select("p_brand", "sorted_sizes") .sort("p_brand") .limit(50) )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_sort'])For the DataFrame form:
from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('read_primitives', 'array_sort', family="expression").source) # or family="pandas"Source
Query text: benchbox/core/read_primitives/queries.py