Skip to content

Fix the endless loop in Join and Merge when both suffixes are the same - #7692

Open
HuzaifaChaudary wants to merge 1 commit into
dotnet:mainfrom
HuzaifaChaudary:fix/join-same-suffix-infinite-loop
Open

Fix the endless loop in Join and Merge when both suffixes are the same#7692
HuzaifaChaudary wants to merge 1 commit into
dotnet:mainfrom
HuzaifaChaudary:fix/join-same-suffix-infinite-loop

Conversation

@HuzaifaChaudary

Copy link
Copy Markdown

Fixes #6128

Join and Merge rename a column that appears in both frames . the existing one gets
leftSuffix , the new one gets rightSuffix , and it repeats until the two names are
different . when both suffixes are the same string the names stay equal after every round , so
nothing ever ends the loop and both names keep growing .

the reporter hit it by passing the join column name where the suffix goes . michaelgsharp
already named the cause on the issue in 2022 , this is just the patch for it .

it now throws an ArgumentException naming the two parameters and the column .

the check is inside SetSuffixForDuplicatedColumnNames rather than up front in Join and
Merge , because equal suffixes are fine when the two frames share no column name . nothing
gets renamed in that case and it works today , so an up front check would break it . i
measured that before deciding where to put it :

join , shared column name , same suffix        hangs , all four algorithms
join , no shared column name , same suffix     fine
merge , shared column name , same suffix       hangs
merge , default suffixes                       fine

three tests added . the first covers all four JoinAlgorithm values with "_same"/"_same"
and with ""/"" , then checks "_left"/"_right" still gives the full column set . the second
goes the other way and pins that equal suffixes are still allowed when nothing collides . the
third is the same thing for Merge .

worth saying how the without-the-fix run looks , since it is not an ordinary failure . the
defect is an endless loop , so the tests do not go red , they never finish . i took the fix out
and the run was still going after 150 seconds with no result , at about 92 percent cpu . with
the fix the same six tests finish in 43 ms .

Microsoft.Data.Analysis.Tests is 483 passing , 0 failures , 5 skipped . the tree without this
runs 477 , so the only difference is the six new ones . build is clean with
EnforceCodeStyleInBuild.

i also grepped every .Join( and .Merge( caller in src and test , none of them pass
equal suffixes , so the new guard cannot fire on existing code .

SetSuffixForDuplicatedColumnNames renames a column that is in both frames. the
existing one gets leftSuffix and the new one gets rightSuffix, and it repeats
until the two names differ. when both suffixes are the same string the names
stay equal after every round, so nothing ends the loop and both names grow
forever.

it now throws an ArgumentException naming the two parameters and the column.
the check sits inside the helper rather than in Join and Merge, because equal
suffixes are fine when the two frames share no column name, and nothing is
renamed in that case.
Copilot AI lite review requested due to automatic review settings September 5, 2026 23:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Microsoft.Data.Analysis DataFrame.Join infinite loop

2 participants