Skip to content

Introduce datatable.unique.names policy for duplicate handling in setnames() #4044#7647

Open
venom1204 wants to merge 3 commits intomasterfrom
issuenight
Open

Introduce datatable.unique.names policy for duplicate handling in setnames() #4044#7647
venom1204 wants to merge 3 commits intomasterfrom
issuenight

Conversation

@venom1204
Copy link
Contributor

closes #4044
This PR introduces a configurable policy for handling duplicate column names created by setnames().

Changes introduced:

Added a new global option datatable.unique.names (default: "off") to preserve backward compatibility.

Supported policies:

  • "off" – Allow duplicates silently (current behavior).
  • "warn" – Issue a warning when duplicates are created.
  • "error" – Stop execution if duplicates would be created.
  • "rename" – Automatically enforce uniqueness using make.unique().

Added a centralized helper process_name_policy() in utils.R to handle duplicate detection and enforcement.

Integrated the policy check into setnames() before reference updates to ensure keys and indices are not corrupted in "error" or "rename" modes.

  • Added validation for invalid option values with a warning and safe fallback to "off".
  • The default behavior remains unchanged, and performance is preserved in the "off" fast path.

hi @ben-schwen , when you have time could you please take a look?
thanks.

@github-actions
Copy link

github-actions bot commented Feb 25, 2026

No obvious timing issues in HEAD=issuenight
Comparison Plot

Generated via commit 88085d1

Download link for the artifact containing the test results: ↓ atime-results.zip

Task Duration
R setup and installing dependencies 5 minutes and 44 seconds
Installing different package versions 11 minutes and 46 seconds
Running and plotting the test cases 4 minutes and 18 seconds

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.

Should setnames() produce duplicate column names without warning?

1 participant