Skip to content

Fix notHas key type compatibility - #115233

Closed
alexey-milovidov wants to merge 95 commits into
masterfrom
fix/not-has-key-type-compatibility
Closed

alexey-milovidov wants to merge 95 commits into
masterfrom
fix/not-has-key-type-compatibility

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

Prevent KeyCondition from compiling has / notHas constant arrays into set atoms when raw Field equality differs from conversion to the primary-key type. This avoids incorrect pruning for representable cross-type values such as String against Enum.

Related: #109926

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):

...


Workflow [PR]
Sync PR [sync-upstream/pr/115233]

alesapin and others added 30 commits March 13, 2026 14:36
Adapt the mutation partition-pruning feature to the refactored
`MutationCommand`, which no longer stores parsed `partition`/`predicate`
members. On master a `MutationCommand` serializes the alter command into
`ast_text` and re-parses it on demand via `MutationCommand::ast`, so all
access to the command's partition/predicate now goes through
`command.ast()->...`. The new multi-partition `IN PARTITION p1, p2, ...`
support is carried in the `ASTAlterCommand::partitions` field, which is
round-tripped through `ast_text` (parser, `clone`, `formatImpl` and
`forEachPointerToChild` all handle it).

Also resolved the `optimize_mutations_with_partition_pruning` setting
declaration (master relocated `use_partition_pruning`) and the updated
`MutationCommand::parse` signature.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Fix compilation against APIs that changed on master while this branch
was open:

- `IStorage::getInMemoryMetadataPtr` now requires `(ContextPtr, bool
  bypass_metadata_cache)`; pass `(query_context, false)` in
  `getPartitionIdsPrunedByPredicate`.
- `ActionsDAGWithInversionPushDown` gained a `bool boolean_context`
  parameter; pass `true` (partition pruning analyzes a `WHERE` predicate
  as a filter, matching the other index-analysis call sites).
- `StorageReplicatedMergeTree.cpp` now dereferences the parsed
  `ASTAlterCommand` returned by `MutationCommand::ast`, so include
  `Parsers/ASTAlterQuery.h` for the complete type.

Verified all touched translation units pass `-fsyntax-only` against the
current master headers.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…utation-partition-pruning

# Conflicts:
#	src/Core/Settings.cpp
#	src/Interpreters/MutationsInterpreter.cpp
#	src/Storages/MergeTree/MergeTreeData.cpp
alexey-milovidov and others added 21 commits August 8, 2026 01:43
The 2026-08-10 master merge brought in the same Analyzer/Planner headers
that this PR had added for the analyzer-mode pruning path, so
`Analyzer/TableNode.h`, `Analyzer/Resolve/QueryAnalyzer.h`,
`Planner/PlannerContext.h` and `Planner/CollectTableExpressionData.h`
ended up included twice, failing the `Build (arm_tidy)` CI job:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110968&sha=f522814bfd0224913648939766dabee21c9609d8&name_0=PR&name_1=Build%20%28arm_tidy%29

Co-Authored-By: Claude Fable 5 <[email protected]>
A single `ALTER TABLE` with several mutation commands is the only place
where `getPartitionIdsAffectedByCommands` unions explicit `IN PARTITION`
scopes with pruned predicate scopes and intersects the per-command
analyzed snapshots, but all existing tests used one command per
statement. The new test covers two pruned commands, a mixed
explicit/pruned statement, and a pruned command combined with a command
that cannot be scoped (which must widen to all partitions), asserting
the scope via `system.mutations.block_numbers.partition_id`.

Requested by the AI review: #110968 (comment)

Co-Authored-By: Claude Fable 5 <[email protected]>
Update the `validate_mutation_query` documentation input so CI regenerates the `Setting` enum after this PR starts referencing `Setting::validate_mutation_query`.

CI: https://github.com/ClickHouse/ClickHouse/actions/runs/31908710379
Do not prune unresolved subqueries for lightweight updates: their allocated partition block numbers constrain the parts read during execution.

#110968
@clickhouse-gh

clickhouse-gh Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f764c5a]

Summary: ❌

job_name test_name status info comment
Fast test FAIL
03773_deterministic_functions_key_condition_explain FAIL cidb
03904_has_function_partition_pruning_key_condition FAIL cidb
03733_has_function_key_condition_explain FAIL cidb
03762_has_in_function_key_condition_deterministic_function_chain_explain FAIL cidb
Code Review DROPPED
Fast test (arm_darwin) DROPPED
Build (amd_debug) DROPPED
Build (amd_asan_ubsan) DROPPED
Build (amd_tsan) DROPPED
Build (amd_msan) DROPPED
Build (amd_binary) DROPPED
Build (arm_debug) DROPPED
Build (arm_asan_ubsan) DROPPED

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Aug 18, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Superseded by #115294. The original branch was structurally stacked on unrelated mutation-pruning history; this replacement targets directly with only the intended compatibility fix.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Correction: the replacement targets master directly with only the intended compatibility fix.

@mintlify

mintlify Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
ClickHouse-docs 🟢 Ready View Preview Aug 20, 2026, 6:37 AM

This branch was successfully deployed

1 active deployment
staging - docs — f764c5af Deployed Aug 20, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants