Skip to content

Add test: Trivial count with AND of partition column and non-deterministic function on partitioned MergeTree is untested - #103893

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

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

Conversation

@clickgapai

Copy link
Copy Markdown
Contributor

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

Retrospective finding from a historical scan of PR #60586 (merged 2024-03-13). Confirmed on current codebase — close with a note if already fixed.

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 #60586.
That PR PR #60586 fixes wrong results when reading from MergeTree with non-deterministic functions (e.g. rand()) in the filter. Three changes: (1) adds new VirtualColumnUtils::isDeterministicInScopeOfQuery helper that recursively checks if all functions in an ActionsDAG subtree are deterministic in

1. Trivial count with AND of partition column and non-deterministic function on partitioned MergeTree is untested
src/Storages/MergeTree/MergeTreeData.cpp:1702, src/Storages/VirtualColumnUtils.cpp:627
Risk: PR test 03002 only covers TOP-LEVEL non-deterministic filter (RAND() > X) on a non-partitioned MergeTree — that path hits line 627 directly without going through AND-internal propagation. Risk: if
What's unique vs PR tests: PR test 03002 covers a TOP-LEVEL non-deterministic filter (WHERE RAND() > X) on a NON-PARTITIONED MergeTree — that exercises only the direct `else if (!isDeterministicInScopeOfQuery(node)) return
Try it on ClickHouse Fiddle

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)

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

clickhouse-gh Bot commented May 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4d0277e]

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 May 2, 2026
@clickgapai

Copy link
Copy Markdown
Contributor Author

CI check Finish Workflow failed, but the failure does not reference this PR's test (04201_merge_tree_partition_count_with_rand_filter).

This PR is test-only; the bot will not retrigger CI or modify the test to chase a failure that appears unrelated. If you believe the failure is related to this test, please comment with details and the bot will re-evaluate.

@clickgapai

Copy link
Copy Markdown
Contributor Author

This PR has accumulated 5 CI failures that don't reference its test, so the bot has not attempted any fix. Closing — please re-run CI or comment if you'd like the bot to look again.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ alexey-milovidov
❌ ClickGap AI Bot


ClickGap AI Bot seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@clickgapai

Copy link
Copy Markdown
Contributor Author

CI failure in Config Workflow 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

@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/VirtualColumnUtils.cpp:627 still present; test passes on master 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

Not re-filing this one, and here is the reason rather than silence.

03203_count_with_non_deterministic_function.sql:3-4 already covers this. rand() and rowNumberInAllBlocks() carry identical determinism flags (FunctionsRandom.h:60-61, rowNumberInAllBlocks.cpp:42-50), so both converge on the same bail-out at VirtualColumnUtils.cpp:635, and 03203 is the guard's own regression test: it asserts an exact result under both analyzers rather than a count.

Two nearby branches genuinely are uncovered, but neither is what this test targets: the or arm at VirtualColumnUtils.cpp:682 returns on any null child with no partial-result test, and totalRowsByPartitionPredicateImpl has a second bail-out at MergeTreeData.cpp:2078. Those are worth their own tests rather than being folded into this one.

The other six gaps from this batch's MergeTree/index group are resolved in #114305.

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.

5 participants