Read Primitives — Broadcast Join (3 tables)
Read Primitives benchmark · all Read Primitives queries
Two small tables broadcast to join with one large table
Representative SQL
Rendered for DataFusion with default parameters.
/* + BROADCAST(n, r) */SELECT r.r_name, n.n_name, COUNT(*) AS supplier_countFROM supplier AS sJOIN nation AS n ON s.s_nationkey = n.n_nationkeyJOIN region AS r ON n.n_regionkey = r.r_regionkeyGROUP BY r.r_name, n.n_nameRepresentative DataFrame
Expression family (Polars, PySpark, DataFusion), default parameters.
def broadcast_join_three_tables_expression_impl(ctx: DataFrameContext) -> Any: return ( ctx.get_table("supplier") .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") .group_by("r_name", "n_name") .agg(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 factorqueries = bench.get_queries(dialect="datafusion") # your platform's dialect; drop dialect= for native SQLprint(queries['broadcast_join_three_tables'])For the DataFrame form:
from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('read_primitives', 'broadcast_join_three_tables', family="expression").source) # or family="pandas"Source
Query text: benchbox/core/read_primitives/queries.py