Skip to content

Commit 9fbc211

Browse files
committed
docs: add implementation notes for requalify_sides_if_needed function
1 parent d8cf07b commit 9fbc211

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

datafusion/expr/src/logical_plan/builder.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,6 +1744,14 @@ pub fn requalify_sides_if_needed(
17441744
// 1. Duplicate qualified fields: both sides have same relation.name
17451745
// 2. Duplicate unqualified fields: both sides have same unqualified name
17461746
// 3. Ambiguous reference: one side qualified, other unqualified, same name
1747+
//
1748+
// Implementation note: This uses a simple O(n*m) nested loop rather than
1749+
// a HashMap-based O(n+m) approach. The nested loop is preferred because:
1750+
// - Schemas are typically small (per TPCH benchmark, max is 16 columns),
1751+
// so n*m is negligible
1752+
// - Early return on first conflict makes common case very fast
1753+
// - Code is simpler and easier to reason about
1754+
// - Called only during plan construction, not in execution hot path
17471755
for l in &left_cols {
17481756
for r in &right_cols {
17491757
if l.name != r.name {

0 commit comments

Comments
 (0)