Skip to content

test: correct feature gating of two datafusion-common tests#23044

Merged
neilconway merged 2 commits into
apache:mainfrom
Phoenix500526:fix/common-test-feature-gates
Jun 19, 2026
Merged

test: correct feature gating of two datafusion-common tests#23044
neilconway merged 2 commits into
apache:mainfrom
Phoenix500526:fix/common-test-feature-gates

Conversation

@Phoenix500526

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

  • N/A — two small, unrelated-to-features test-gating fixes in datafusion-common found while building the crate's tests under non-default feature sets.

Rationale for this change

Two #[cfg] feature-gating issues in datafusion-common test code:

  1. test_create_hashes_with_quality_hash_state asserts that create_hashes
    reproduces a specific high-quality hash distribution. Under the
    force_hash_collisions feature, create_hashes is replaced by a stub that
    writes all-zero hashes, so the exact-value assertion fails — this breaks the
    cargo test hash collisions CI job. Every other exact-hash-value test in
    that module is already gated with #[cfg(not(feature = "force_hash_collisions"))];
    this one was missing the gate.

  2. The test-only use sqlparser::ast::Ident; in utils::tests is used solely by
    test_quote_identifier, which is #[cfg(feature = "sql")]. Building the tests
    without the sql feature leaves the import unused and emits an
    unused_imports warning.

What changes are included in this PR?

  • Gate test_create_hashes_with_quality_hash_state with
    #[cfg(not(feature = "force_hash_collisions"))].
  • Gate the test-only Ident import with #[cfg(feature = "sql")] to match its
    sole user.

Both are test-only changes; no production code is touched.

Are these changes tested?

Verified via the existing tests:

  • With --features force_hash_collisions, test_create_hashes_with_quality_hash_state
    is now excluded (no longer fails the forced-collision build); without the
    feature it still compiles and passes.
  • Building datafusion-common tests without the sql feature no longer emits
    the unused_imports warning; with sql the import and test_quote_identifier
    are both present.

Are there any user-facing changes?

No.

`test_create_hashes_with_quality_hash_state` asserts that `create_hashes`
reproduces a specific high-quality hash distribution. Under the
`force_hash_collisions` feature `create_hashes` is replaced by a stub that
writes all-zero hashes, so the exact-value assertion fails and breaks the
`cargo test hash collisions` CI job.

Gate the test with `#[cfg(not(feature = "force_hash_collisions"))]`, matching
every other exact-hash-value test in this module, so it is excluded from the
forced-collision build.

Signed-off-by: Jiawei Zhao <Phoenix500526@163.com>
The `use sqlparser::ast::Ident;` in the `utils` test module is only used by
`test_quote_identifier`, which is `#[cfg(feature = "sql")]`. Building the
`datafusion-common` tests without the `sql` feature therefore left the import
unused and emitted an `unused_imports` warning.

Gate the import with `#[cfg(feature = "sql")]` so it is compiled exactly when
its sole user is, removing the warning and keeping the import and its user
consistent across feature combinations.

Signed-off-by: Jiawei Zhao <Phoenix500526@163.com>

@neilconway neilconway 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.

Thanks for the fix @Phoenix500526 ! lgtm

@neilconway neilconway enabled auto-merge June 19, 2026 16:44
@neilconway neilconway added this pull request to the merge queue Jun 19, 2026
Merged via the queue into apache:main with commit efc7b3e Jun 19, 2026
35 checks passed
@Phoenix500526 Phoenix500526 deleted the fix/common-test-feature-gates branch June 20, 2026 01:26
github-merge-queue Bot pushed a commit that referenced this pull request Jun 20, 2026
…_collisions) (#23053)

## Which issue does this PR close?

- N/A — a CI test-gating fix found while building the workspace under
`force_hash_collisions`. Follow-up to #23044, which fixed the equivalent
`datafusion-common` test.

## Rationale for this change

Three `approx_distinct` tests assert exact distinct-count results that
HyperLogLog can only produce with real hashing. Under the
`force_hash_collisions` feature, `create_hashes` forces every hash
equal, so the cardinality estimate collapses to 1 and the assertions
fail — breaking the `cargo test hash collisions` and `extended_tests` CI
jobs:

```
update_batch_nullable_filter_excludes_null_filter_rows
utf8view_groups_short_string_hashed_consistently_across_batches
utf8view_acc_split_batches_match_single_mixed_batch
```

`datafusion-functions-aggregate` did not declare
`force_hash_collisions`, so a plain `#[cfg(not(feature =
"force_hash_collisions"))]` would also raise an `unexpected_cfgs` lint
and never actually fire.

## What changes are included in this PR?

- Forward the feature in `datafusion-functions-aggregate/Cargo.toml`:
`force_hash_collisions = ["datafusion-common/force_hash_collisions"]`,
so the crate recognises it (and it gets enabled under the workspace
`force_hash_collisions` build).
- Gate the three tests (and their test-only imports / helpers) with
`#[cfg(not(feature = "force_hash_collisions"))]`, matching the pattern
already used for the equivalent `datafusion-common` tests.

Test-only changes; no production code is touched.

## Are these changes tested?

- `cargo test -p datafusion-functions-aggregate --features
force_hash_collisions approx_distinct` — the three tests are now
excluded; the rest pass.
- `cargo test -p datafusion-functions-aggregate approx_distinct` (no
feature) — all tests still present and pass.
- `cargo clippy -p datafusion-functions-aggregate --all-targets
--features force_hash_collisions -- -D warnings` — clean.

## Are there any user-facing changes?

No.

---------

Signed-off-by: Jiawei Zhao <Phoenix500526@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants