Skip to content

Read Primitives — Empty Build Side Join

Read Primitives benchmark · all Read Primitives queries

Join when build side produces no rows (edge case handling)

Representative SQL

Rendered for DataFusion with default parameters.

SELECT
l.*
FROM lineitem AS l
LEFT JOIN (
SELECT
*
FROM orders
WHERE
o_totalprice < 0
) AS o
ON l.l_orderkey = o.o_orderkey

Representative DataFrame

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

def empty_build_join_expression_impl(ctx: DataFrameContext) -> Any:
col, lit = ctx.col, ctx.lit
empty_orders = ctx.get_table("orders").filter(col("o_totalprice") < lit(0)).select("o_orderkey")
return (
ctx.get_table("lineitem")
.join(empty_orders, left_on="l_orderkey", right_on="o_orderkey", how="left")
.select(*_LINEITEM_COLS)
)

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

For the DataFrame form:

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

Source

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