Skip to content

Cherry pick #128077 to 26.10: Do not let a derived indexHint keep HAVING above GROUPING SETS - #131336

Merged
robot-ch-test-poll merged 5 commits into
backport/26.10/128077from
cherrypick/26.10/128077
Nov 19, 2026
Merged

robot-ch-test-poll merged 5 commits into
backport/26.10/128077from
cherrypick/26.10/128077

Conversation

@robot-clickhouse

Copy link
Copy Markdown
Member

Original pull-request #128077

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 4 commits October 28, 2026 16:54
Since #126219 the GROUPING SETS check in tryPushDownFilter also counts the
columns that an implied indexHint reads, so that a filter consisting only of
such a hint cannot prune rows below a set that lacks its key. But the hint's
own actions are built from the query tree and read the table column (`k` of
key `intDiv(k, 10)`, `ts` of `toDate(ts)`), which is in no grouping set. The
check then rejected the whole filter, and its other conjuncts (`v < 3`),
which 26.10 pushed to the read, stopped pruning: the query from #128072 read
78/78 granules instead of 3/78.

Collect the hint inputs separately. The filter's own identifiers still gate
it as before. When a hint input is missing from some set, push the filter
with PushDownIndexHints::None, so the other conjuncts go below the
aggregation as on 26.10 and every hint stays above it; otherwise keep
PushDownIndexHints::Implied as on master. Applies to MergingAggregated too.

The existing GROUPING SETS ((a, b), (b)) case of 05401 still returns 0; with
the hints pushed (Implied instead of None) it returns 1.

Closes #128072

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ets-hint-gate-128072

Resolve the conflict in filterPushDown.cpp: master rewrote findIdentifiersOfNode on top of visitReachableNodes; keep that form and route the implied indexHint inputs to the separate set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The plain conjunct `v < 3` prunes to `3/79` on its own, so without a derived
hint the granule check passes whether or not the fix is present (measured with
`optimize_and_compare_chain = 0`). Assert the hint is there first, as the other
cases of this test already do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gate-128072

Do not let a derived `indexHint` keep `HAVING` above `GROUPING SETS`
@robot-clickhouse robot-clickhouse added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request labels Nov 13, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

The only conflict is in findIdentifiersOfNode (filterPushDown.cpp): master moved that walk to visitReachableNodes in #129671, which is not on 26.10 and has no backport label. I kept the 26.10 queue loop and changed only its addImpliedIndexHintInputs call, as #128077 does on master; the rest applies as is. Against backport/26.10/128077 the merge changes only the 3 files of #128077.

The regression this fixes reached 26.10 with #128130 and is not in a release yet. On the 26.10 tree (clang-22, debug) 05401_index_hint_derived_below_group_by passes, 50 of 50 with random settings. The same tree without the src/ change reads Granules: 79/79 instead of 3/79 on the new GROUPING SETS cases, with the same result rows.

I cannot push to cherrypick/26.10/128077. The merge is on my fork and its first parent is this PR's head 8b65eedd35a3, so applying it is a fast-forward:

git fetch https://github.com/groeneai/ClickHouse.git groeneai/resolve-26.10-cherrypick-128077
git push origin FETCH_HEAD:cherrypick/26.10/128077

@robot-clickhouse-ci-2

Copy link
Copy Markdown
Contributor

Dear @nickitat, @groeneai, this cherry-pick PR has not been updated for 3d0h0m3s. Please resolve the conflicts to backport #128077, or close this PR if the backport is no longer needed. This PR will be automatically closed after 7 days of inactivity.

@robot-ch-test-poll

Copy link
Copy Markdown
Contributor

The 26.10 branch moved since this cherry-pick was created (now at 244634a). Re-tried the merge against it and it applies cleanly, so the bot is proceeding without manual resolution.

@robot-ch-test-poll
robot-ch-test-poll merged commit 6c5de3b into backport/26.10/128077 Nov 19, 2026
1 check passed
@robot-ch-test-poll
robot-ch-test-poll deleted the cherrypick/26.10/128077 branch November 19, 2026 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants