Read Primitives — Broadcast Join (4 tables)
Read Primitives benchmark · all Read Primitives queries
Three small tables broadcast to join with one large table
Representative SQL
Rendered for DataFusion with default parameters.
/* + BROADCAST(n, r, p) */SELECT r.r_name, p.p_type, SUM(ps.ps_supplycost * ps.ps_availqty) AS total_valueFROM partsupp AS psJOIN supplier AS s ON ps.ps_suppkey = s.s_suppkeyJOIN nation AS n ON s.s_nationkey = n.n_nationkeyJOIN region AS r ON n.n_regionkey = r.r_regionkeyJOIN part AS p ON ps.ps_partkey = p.p_partkeyWHERE p.p_size = 15GROUP BY r.r_name, p.p_typeRepresentative DataFrame
Expression family (Polars, PySpark, DataFusion), default parameters.
def broadcast_join_four_tables_expression_impl(ctx: DataFrameContext) -> Any: col, lit = ctx.col, ctx.lit return ( ctx.get_table("partsupp") .join(ctx.get_table("supplier"), left_on="ps_suppkey", right_on="s_suppkey") .join(ctx.get_table("nation"), left_on="s_nationkey", right_on="n_nationkey") .join(ctx.get_table("region"), left_on="n_regionkey", right_on="r_regionkey") .join(ctx.get_table("part"), left_on="ps_partkey", right_on="p_partkey") .filter(col("p_size") == lit(15)) .group_by("r_name", "p_type") .agg((col("ps_supplycost") * col("ps_availqty")).sum().alias("total_value")) )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['broadcast_join_four_tables'])For the DataFrame form:
from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('read_primitives', 'broadcast_join_four_tables', family="expression").source) # or family="pandas"Source
Query text: benchbox/core/read_primitives/queries.py