Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: validate duplicate column names in pyarrow and duckdb #1815

Conversation

IsaiasGutierrezCruz
Copy link
Contributor

@IsaiasGutierrezCruz IsaiasGutierrezCruz commented Jan 16, 2025

closes #1920

What type of PR is this? (check all applicable)

  • πŸ’Ύ Refactor
  • ✨ Feature
  • πŸ› Bug Fix
  • πŸ”§ Optimization
  • πŸ“ Documentation
  • βœ… Test
  • 🐳 Other

Related issues

Checklist

  • Code follows style guide (ruff)
  • Tests added
  • [] Documented the changes

If you have comments or can explain your changes, please do so below

To test the validations, I added three methods in the file tests/frame/schema_test.py. @MarcoGorelli, if you think these would be more appropriate in another file, please feel free to let me know. Additionally, I had to add duckdb as a dependency to the extreme GitHub Actions workflow to accommodate these tests.

@MarcoGorelli
Copy link
Member

Thanks! I'll check the perf impact here in case it's significant

@FBruzzesi FBruzzesi added the enhancement New feature or request label Jan 19, 2025
@FBruzzesi
Copy link
Member

Thanks! I'll check the perf impact here in case it's significant

Thinking about this (also in the pandas case), we could add a flag to skip_columns_validation as not every operation from which we return self._from_native_frame(...) might lead to duplicate columns - i.e. select, with_columns, rename can generate duplicate column names, while other ops would not.

@MarcoGorelli
Copy link
Member

yes, we may need from_native_frame and from_native_frame_unchecked

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

thanks @IsaiasGutierrezCruz ! i just added a commit to elide the checks in some cases

@MarcoGorelli MarcoGorelli merged commit f1a9ed1 into narwhals-dev:main Feb 4, 2025
24 checks passed
@IsaiasGutierrezCruz
Copy link
Contributor Author

@MarcoGorelli Thanks for taking care of this PR! Appreciate you getting it over the finish line.
I saw in the comments that cudf does not raise the DuplicateError. I will take a look

@IsaiasGutierrezCruz IsaiasGutierrezCruz deleted the dev/validate_duplicated_column_names branch February 6, 2025 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants