Skip to content

Fix flatten silently dropping data when conflicting column appears after flattened column#17816

Open
tauanbinato wants to merge 1 commit intonushell:mainfrom
tauanbinato:issue/13271-flatten-does-not-rename-conflicting-column-if
Open

Fix flatten silently dropping data when conflicting column appears after flattened column#17816
tauanbinato wants to merge 1 commit intonushell:mainfrom
tauanbinato:issue/13271-flatten-does-not-rename-conflicting-column-if

Conversation

@tauanbinato
Copy link
Copy Markdown
Contributor

@tauanbinato tauanbinato commented Mar 16, 2026

Summary

  • Fix a bug where flatten silently dropped data when the parent record had a conflicting column name that appeared after the column being flattened
  • The conflict detection only checked already-inserted columns, missing conflicts with columns not yet processed
  • Now collects all parent column names upfront into a HashSet before the loop, so conflict detection works regardless of column order
  • Added regression tests for both the table and record cases

Before

> [[b, a]; [[[a]; [9]], 1]] | flatten -a b
╭───┬───╮
 # │ a │
├───┼───┤
 0  1 
╰───┴───╯
# Inner value 9 is silently lost!

After

> [[b, a]; [[[a]; [9]], 1]] | flatten -a b
╭───┬─────┬───╮
 # │ b_a │ a │
├───┼─────┼───┤
 0    9  1 
╰───┴─────┴───╯

Release notes summary

Fixed a bug where flatten would silently drop data when a nested record/table had column names conflicting with parent columns that appeared later in the record. Conflicting columns are now correctly renamed regardless of column order.

Closes #13271

@cptpiepmatz
Copy link
Copy Markdown
Member

The impl looks reasonable, can you look into what is failing in CI here?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flatten does not rename conflicting column if parent's conflicting column appears after column to be flattened

2 participants