Skip to content

Read Primitives — Broadcast Join (2 tables)

Read Primitives benchmark · all Read Primitives queries

One small table broadcast to join with one large table

Representative SQL

Rendered for DataFusion with default parameters.

/* + BROADCAST(n) */
SELECT
COUNT(*) AS supplier_count
FROM supplier AS s
JOIN nation AS n
ON s.s_nationkey = n.n_nationkey

Representative DataFrame

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

def broadcast_join_two_tables_expression_impl(ctx: DataFrameContext) -> Any:
return (
ctx.get_table("supplier")
.join(ctx.get_table("nation"), left_on="s_nationkey", right_on="n_nationkey")
.select(ctx.col("s_suppkey").count().alias("supplier_count"))
)

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

For the DataFrame form:

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

Source

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