Read Primitives — Array Distinct
Read Primitives benchmark · all Read Primitives queries
Get distinct elements from array
Representative SQL
Rendered in the benchmark’s native SQL with default parameters (no dialect translation available).
WITH ship_modes AS ( SELECT l_orderkey, ARRAY_AGG(l_shipmode) AS modes FROM lineitem GROUP BY l_orderkey)SELECT l_orderkey, ARRAY_SORT(ARRAY_DISTINCT(modes)) AS unique_modesFROM ship_modesORDER BY l_orderkeyLIMIT 100Representative DataFrame
Expression family (Polars, PySpark, DataFusion), default parameters.
def array_distinct_expression_impl(ctx: DataFrameContext) -> Any: col = ctx.col
return ( _expr_grouped_list(ctx, "lineitem", "l_orderkey", "l_shipmode", "modes") .with_columns(col("modes").list.unique().list.sort().alias("unique_modes")) .select("l_orderkey", "unique_modes") .sort("l_orderkey") .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_distinct'])For the DataFrame form:
from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('read_primitives', 'array_distinct', family="expression").source) # or family="pandas"Source
Query text: benchbox/core/read_primitives/queries.py