Skip to content

Read Primitives — Map Construction

Read Primitives benchmark · all Read Primitives queries

Construct map from key-value pairs

Representative SQL

Rendered for DataFusion with default parameters.

SELECT
ps_suppkey,
MAP(ARRAY_AGG(CAST(ps_partkey AS VARCHAR)), ARRAY_AGG(ps_supplycost)) AS part_costs
FROM partsupp
WHERE
ps_suppkey <= 10
GROUP BY
ps_suppkey
ORDER BY
ps_suppkey

Representative DataFrame

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

def map_construction_expression_impl(ctx: DataFrameContext) -> Any:
return _partsupp_map_expression(ctx, 10).select("ps_suppkey", "part_costs")

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['map_construction'])

For the DataFrame form:

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

Source

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