Skip to content

chore: Remove duplicate imports in test code#21061

Merged
alamb merged 1 commit intoapache:mainfrom
neilconway:neilc/chore-duplicate-imports
Mar 21, 2026
Merged

chore: Remove duplicate imports in test code#21061
alamb merged 1 commit intoapache:mainfrom
neilconway:neilc/chore-duplicate-imports

Conversation

@neilconway
Copy link
Contributor

Which issue does this PR close?

N/A

Rationale for this change

clippy doesn't warn about use statements that re-import an item that is already available via a glob import (use super::*), but in many cases the use statement is redundant and can be safely removed. In particular, there was a lot of test code that did both use super::* and also imported items that were imported by the module under test; the test-specific import can be safely removed.

What changes are included in this PR?

  • Mechanical removal of duplicate imports between test code and code under test

Are these changes tested?

Yes, via cargo check and cargo clippy

Are there any user-facing changes?

No.

@github-actions github-actions bot added logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates optimizer Optimizer rules core Core DataFusion crate substrait Changes to the substrait crate catalog Related to the catalog crate common Related to common crate execution Related to the execution crate proto Related to proto crate functions Changes to functions implementation datasource Changes to the datasource crate ffi Changes to the ffi crate physical-plan Changes to the physical-plan crate spark labels Mar 19, 2026
@neilconway
Copy link
Contributor Author

@martin-g I was curious why clippy didn't catch the duplicate imports in #20804; turns out that there are a bunch of other duplicate imports we can cleanup.

@martin-g
Copy link
Member

I am also not aware of any clippy setting to warn about such "duplicates".
I am curious what command did you use to identify the imports removed in this PR ?

@neilconway
Copy link
Contributor Author

I am curious what command did you use to identify the imports removed in this PR ?

I first asked Claude Code to see if it could do it; it was a bit slow and unreliable doing it itself, but eventually it decided to write a Python script (attached) that seems like it works pretty well.
fix_redundant_imports.py

@alamb alamb added this pull request to the merge queue Mar 21, 2026
@alamb
Copy link
Contributor

alamb commented Mar 21, 2026

This is great -- thank you @neilconway and @martin-g

Merged via the queue into apache:main with commit 415bd42 Mar 21, 2026
34 checks passed
@neilconway neilconway deleted the neilc/chore-duplicate-imports branch March 21, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

catalog Related to the catalog crate common Related to common crate core Core DataFusion crate datasource Changes to the datasource crate execution Related to the execution crate ffi Changes to the ffi crate functions Changes to functions implementation logical-expr Logical plan and expressions optimizer Optimizer rules physical-expr Changes to the physical-expr crates physical-plan Changes to the physical-plan crate proto Related to proto crate spark substrait Changes to the substrait crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants