Skip to content

Read Primitives — List Transform

Read Primitives benchmark · all Read Primitives queries

Transform each array element

Representative SQL

Rendered in the benchmark’s native SQL with default parameters (no dialect translation available).

WITH part_prices AS (
SELECT
p_brand,
ARRAY_AGG(p_retailprice) AS prices
FROM part
GROUP BY
p_brand
)
SELECT
p_brand,
TRANSFORM(prices, x -> x * 1.1) AS prices_with_tax
FROM part_prices
ORDER BY
p_brand
LIMIT 50

Representative DataFrame

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

def list_transform_expression_impl(ctx: DataFrameContext) -> Any:
col = ctx.col
lit = ctx.lit
elem = ctx.element()
return (
_expr_grouped_list(ctx, "part", "p_brand", "p_retailprice", "prices")
.with_columns(col("prices").list.eval(elem * lit(1.1)).alias("prices_with_tax"))
.select("p_brand", "prices_with_tax")
.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 factor
queries = bench.get_queries(dialect="datafusion") # your platform's dialect; drop dialect= for native SQL
print(queries['list_transform'])

For the DataFrame form:

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

Source

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