Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions benchmarks/sql_benchmarks/nlj/benchmarks/q18.benchmark
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name Q18
group nlj

expect_plan NestedLoopJoinExec
expect_plan join_type=RightSemi

run
-- Q18: RIGHT SEMI 4K x 4K | no matches; the maximum sum is 4096 * 4096 - 1
SELECT r.value
FROM range(4096) AS l
RIGHT SEMI JOIN range(4096) AS r
ON l.value * 4096 + r.value >= 4096 * 4096;
12 changes: 12 additions & 0 deletions benchmarks/sql_benchmarks/nlj/benchmarks/q19.benchmark
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name Q19
group nlj

expect_plan NestedLoopJoinExec
expect_plan join_type=RightAnti

run
-- Q19: RIGHT ANTI 4K x 4K | no matches; the maximum sum is 4096 * 4096 - 1
SELECT r.value
FROM range(4096) AS l
RIGHT ANTI JOIN range(4096) AS r
ON l.value * 4096 + r.value >= 4096 * 4096;
28 changes: 28 additions & 0 deletions benchmarks/sql_benchmarks/nlj/benchmarks/q20.benchmark
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name Q20
group nlj

expect_plan NestedLoopJoinExec
expect_plan join_type=RightSemi

run
-- Q20: RIGHT SEMI 2K x 2K | staged matches with 260-byte filter strings
-- With batch_size=8192, candidates shrink 2048 -> 1024 -> 512 -> ... -> 16.
-- Under that setting, the multi-left-row path starts at 512 candidates.
SELECT r.value
FROM (
SELECT repeat('x', 256) || lpad(CAST(
CASE WHEN value < 128 THEN 1024
WHEN value < 256 THEN 1536
WHEN value < 384 THEN 1792
WHEN value < 512 THEN 1920
WHEN value < 640 THEN 1984
WHEN value < 768 THEN 2016
ELSE 2032 END AS VARCHAR), 4, '0') AS threshold
FROM range(2048)
) AS l
RIGHT SEMI JOIN (
SELECT value,
repeat('x', 256) || lpad(CAST(value AS VARCHAR), 4, '0') AS key
FROM range(2048)
) AS r
ON l.threshold > r.key;
28 changes: 28 additions & 0 deletions benchmarks/sql_benchmarks/nlj/benchmarks/q21.benchmark
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name Q21
group nlj

expect_plan NestedLoopJoinExec
expect_plan join_type=RightAnti

run
-- Q21: RIGHT ANTI 2K x 2K | staged matches with 260-byte filter strings
-- With batch_size=8192, candidates shrink 2048 -> 1024 -> 512 -> ... -> 16.
-- Under that setting, the multi-left-row path starts at 512 candidates.
SELECT r.value
FROM (
SELECT repeat('x', 256) || lpad(CAST(
CASE WHEN value < 128 THEN 1024
WHEN value < 256 THEN 1536
WHEN value < 384 THEN 1792
WHEN value < 512 THEN 1920
WHEN value < 640 THEN 1984
WHEN value < 768 THEN 2016
ELSE 2032 END AS VARCHAR), 4, '0') AS threshold
FROM range(2048)
) AS l
RIGHT ANTI JOIN (
SELECT value,
repeat('x', 256) || lpad(CAST(value AS VARCHAR), 4, '0') AS key
FROM range(2048)
) AS r
ON l.threshold > r.key;
29 changes: 29 additions & 0 deletions benchmarks/sql_benchmarks/nlj/benchmarks/q22.benchmark
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name Q22
group nlj

expect_plan NestedLoopJoinExec
expect_plan join_type=RightSemi

# Materialize the threshold so the filter keeps both join inputs.
# Keep the left input smaller so the default optimizer preserves RightSemi.
init
CREATE TABLE nlj_repeated_left AS
SELECT 3277 AS threshold FROM range(4096);

init
CREATE TABLE nlj_repeated_right AS
SELECT value AS id FROM range(8192);

run
-- Repeated 40% matches: only the first probe adds matches.
-- With one partition and batch_size=8192, 4915 survivors exceed the 4096-row
-- compaction threshold, so every left row probes the full right batch.
SELECT r.id
FROM nlj_repeated_left l
RIGHT SEMI JOIN nlj_repeated_right r ON l.threshold > r.id;

cleanup
DROP TABLE nlj_repeated_left;

cleanup
DROP TABLE nlj_repeated_right;
32 changes: 32 additions & 0 deletions benchmarks/sql_benchmarks/nlj/benchmarks/q23.benchmark
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name Q23
group nlj

expect_plan NestedLoopJoinExec
expect_plan join_type=RightAnti

init
CREATE TABLE nlj_final_left AS
SELECT arrow_cast('m', 'Utf8') AS threshold;

# Materialize 32 MiB of Utf8 strings outside the measured query. Compaction
# would copy these strings; different first bytes keep comparison cheap.
init
CREATE TABLE nlj_final_right AS
SELECT value AS id,
arrow_cast((CASE WHEN value < 4096 THEN 'a' ELSE 'z' END)
|| repeat('x', 4095), 'Utf8') AS payload
FROM range(8192);

run
-- With one partition and batch_size=8192, half the batch survives the only
-- left row. Compacting after that final probe would needlessly copy 16 MiB.
-- Return IDs only to exclude string copying from output materialization.
SELECT r.id
FROM nlj_final_left l
RIGHT ANTI JOIN nlj_final_right r ON l.threshold > r.payload;

cleanup
DROP TABLE nlj_final_left;

cleanup
DROP TABLE nlj_final_right;
Loading
Loading