Skip to content

Add test: Non-fitting String literal vs LowCardinality(FixedString) functional key: NULL-found bail-out (KeyCondition.cpp:2054) untested - #108815

Closed
clickgapai wants to merge 2 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr108777
Closed

clickgapai wants to merge 2 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr108777

Conversation

@clickgapai

Copy link
Copy Markdown
Contributor

Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.

This is a test-only PR — no source code changes. Please review: test quality, whether the claimed coverage gaps are real, and whether test output makes sense.

Adds test coverage for 1 untested code path(s), found during automated review of PR #108777.
That PR The PR fixes applyDeterministicDagToColumn (src/Storages/MergeTree/KeyCondition.cpp) so partition/key pruning is no longer silently disabled when a LowCardinality(FixedString) (or LowCardinality(Nullable(FixedString))) key column is wrapped in a function in the key (e.g. `PARTITION BY sipHas

1. Non-fitting String literal vs LowCardinality(FixedString) functional key: NULL-found bail-out (KeyCondition.cpp:2054) untested
src/Storages/MergeTree/KeyCondition.cpp:2054
Risk: Call chain: partition-pruning builds the key transform DAG for sipHash64(k) % 8; to push the WHERE constant into key space applyDeterministicDagToColumn calls cast_without_nulls(String '...', LowCardinality(FixedString(8))); canBeSafelyCast is false so it probes via removeLowCardinality(target) = FixedString(8); an over-length literal makes castColumnAccurateOrNull return NULL, the loop at 2052-2054 finds it and returns false. RISK: if this guard is removed/inverted, execution …
What's unique vs PR tests: The PR's 04401 test only uses literals that FIT the FixedString length (8-char strings into FixedString(8)), exercising the no-NULL path that ends in castColumnAccurate succeeding. This test drives a literal that does NOT fit, taking the NULL-found return false branch at line 2054 that 04401 never reaches.

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Not applicable — test-only change.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickgapai

Copy link
Copy Markdown
Contributor Author

Pre-PR Validation Gate (per ClickGap pipeline):

a) Deterministic repro? ✅
Test exercises the previously-uncovered branch and passes (correct behaviour).

b) Root cause explained? ✅
src/Storages/MergeTree/KeyCondition.cpp:2052-2054 — for (char8_t b : n.getNullMapData()) if (b) return false; the NULL-found return is reachable only when the probe cast introduces NULLs (constant does not fit the key type); PR tests only fitting literals so this branch is uncovered (LLVM line 2054 >>).

c) Fix matches root cause? ✅
N/A for coverage gap — this PR adds a regression test, not a fix. Asserts current correct behaviour at the cited line.

d) Test intent preserved? / New tests added? ✅
New regression test added: 04489_lc_fixed_string_partition_prune_overlong_literal.sql.

e) Both directions demonstrated? ✅
Test passes (MATCH) on master proving current correctness; would fail if the cited branch regressed. Single-direction is the correct shape for a coverage gap test.

f) Fix is general, not a narrow patch? ✅
Test asserts the invariant at the cited line — covers the branch, not a specific input shape.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 29, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [68cf8fe]

Summary: ❌

job_name test_name status info comment
Config Workflow ERROR
Dockers Build (amd) DROPPED
Dockers Build (arm) DROPPED
Dockers Build (multiplatform manifest) DROPPED
Style check DROPPED
Code Review DROPPED
Docs check DROPPED
Docs check (Mintlify) DROPPED
Fast test DROPPED
CI Tests DROPPED

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jun 29, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.40% 85.40% +0.00%
Functions 92.60% 92.60% +0.00%
Branches 77.60% 77.60% +0.00%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 330 line(s), 11 function(s) across 120 file(s) · Details

Top files
  • src/Storages/WindowView/StorageWindowView.cpp: 22 line(s), 1 function(s)
  • src/Common/ZooKeeper/ZooKeeper.cpp: 10 line(s)
  • src/IO/AzureBlobStorage/PocoHTTPClient.cpp: 10 line(s)
  • src/IO/CachedInMemoryReadBufferFromFile.cpp: 9 line(s), 1 function(s)
  • src/Common/PageCache.cpp: 7 line(s), 1 function(s)

Full report

@clickgapai

Copy link
Copy Markdown
Contributor Author

CI failure in Stateless tests (amd_tsan, s3 storage, parallel, 2/2) appears to be unrelated breakage and is not related to this change. Let me know if you'd like me to merge master and retrigger CI.

@zlareb1

zlareb1 commented Aug 10, 2026

Copy link
Copy Markdown
Member

@clickgapai fix the CI failures

@clickgapai

Copy link
Copy Markdown
Contributor Author

Can't retrigger CI — this finding no longer has an active PR to act on. If the underlying issue still matters, opening a fresh PR / issue would let me act.

@zlareb1

zlareb1 commented Aug 10, 2026

Copy link
Copy Markdown
Member

@groeneai can you take this up and open a new PR?

@zlareb1 zlareb1 closed this Aug 10, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

Taking this up. Triaged against master 2850e469dcac84b before answering.

Verified: src/Storages/MergeTree/KeyCondition.cpp:2054 still present; test passes and output matches the reference.

It will be re-filed as part of an area-grouped PR rather than its own PR, to keep reviewer load down (26 in this batch plus 18 from the earlier one today). Full triage and the grouping plan: #101781 (comment)

@groeneai

Copy link
Copy Markdown
Collaborator

Re-filed as #114305, the MergeTree/index group, though as two rows appended to the existing 04401_low_cardinality_fixed_string_partition_pruning rather than a new file: that test already builds the same four LowCardinality(FixedString) partition-key fixtures, and this gap is the same fixture with a literal that does not fit the key column.

One correction to the original. The cited line is the function's opening line, not the bail-out. applyDeterministicDagToColumn has four reachable return false sites for this input; a 13-character literal against FixedString(8) lands at the castColumnAccurateOrNull probe (KeyCondition.cpp:2105-2112), which finds a NULL because the value cannot fit. Checked that nothing truncates it earlier: convertFieldToType only zero-extends when the string is shorter than n.

The appended rows assert that no partition condition is built for that literal and that the result is still correct. They sit next to four sibling rows asserting the opposite for fitting literals, so a plan-format change cannot satisfy the new absence assertion silently.

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

Labels

can be tested Allows running workflows for external contributors pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants