Skip to content

Read Primitives — IN Predicate with Subquery

Read Primitives benchmark · all Read Primitives queries

IN predicate with subquery and selective filtering

Representative SQL

Rendered for DataFusion with default parameters.

SELECT
*
FROM part
WHERE
p_partkey IN (
SELECT
l_partkey
FROM lineitem
WHERE
l_quantity > 45
)

Representative DataFrame

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

def filter_in_predicate_subquery_expression_impl(ctx: DataFrameContext) -> Any:
high_qty = ctx.get_table("lineitem").filter(ctx.col("l_quantity") > ctx.lit(45)).select("l_partkey").unique()
return ctx.get_table("part").join(high_qty, left_on="p_partkey", right_on="l_partkey", how="semi")

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

For the DataFrame form:

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

Source

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