Skip to content

Fix index analysis with session_timezone specified - #87987

Merged
azat merged 2 commits into
ClickHouse:masterfrom
korowa:fix-sess-tz-index-analysis
Oct 13, 2025
Merged

azat merged 2 commits into
ClickHouse:masterfrom
korowa:fix-sess-tz-index-analysis

Conversation

@korowa

@korowa korowa commented Oct 1, 2025 •

Copy link
Copy Markdown
Contributor

Closes #86654

  • The main issue was caused by rebuilding key functions chain using the query context (which inferred timezone into the functions)
  • Disabling index analysis for indexes containing date parsing functions in case the query specifies non-empty session timezone, and parsing datetime from string is required, as this part is not working properly since at least 24.1 (example)

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fix for incorrect granules/partitions elimination for datetime-based keys, when using session_timezone setting in queries

Fixes: #65335

@azat azat self-assigned this Oct 6, 2025
@azat azat added the can be tested Allows running workflows for external contributors label Oct 6, 2025
@clickhouse-gh

clickhouse-gh Bot commented Oct 6, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2eddddd]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_asan, old analyzer, 1/6) failure
test_ttl_replicated/test.py::test_ttl_compatibility[node_left2-node_right2-2] FAIL
Integration tests (amd_binary, 2/5) failure
test_merge_tree_s3/test.py::test_merge_canceled_by_s3_errors[node-broken_s3_always_multi_part] FAIL

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Oct 6, 2025

@azat azat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL at the test failures, by some reason test with xxHash32 failed

Comment thread src/Storages/MergeTree/KeyCondition.cpp Resolved
Comment thread src/Storages/MergeTree/KeyCondition.cpp Resolved
@korowa
korowa marked this pull request as draft October 7, 2025 08:36
@korowa
korowa force-pushed the fix-sess-tz-index-analysis branch 4 times, most recently from d3665f7 to 43ba03b Compare October 10, 2025 05:09
@korowa
korowa marked this pull request as ready for review October 10, 2025 07:55
@korowa

korowa commented Oct 10, 2025

Copy link
Copy Markdown
Contributor Author

Integration tests (amd_binary, 2/5)

#87560

Integration tests (amd_tsan, 4/6)

#88328

Stateless tests (amd_tsan, parallel, 2/2)

Unrelated, 00159_parallel_formatting_http has couple of failures on the TSAN builds related to curl timeouts, will check if the query can be less heavy.

Comment thread src/Storages/MergeTree/KeyCondition.cpp Resolved
- The main issue was caused by rebuilding key functions chain
  using the new context (which inferred timezone into the functions).
  Since now function chain will return the original functions from
  tables key, all the LowCardinality handling performed while applying
  the chain of functions.
- Disabling index analysis for indexes containing date parsing functions
  in case the query specifies non-empty session timezone, and it's required
  to parse datetime from string, as this part is not working properly since
  at least 24.1.
@korowa
korowa force-pushed the fix-sess-tz-index-analysis branch from 43ba03b to 9face16 Compare October 10, 2025 15:57
@azat
azat enabled auto-merge October 10, 2025 16:15
@azat azat added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Oct 10, 2025
@azat

azat commented Oct 11, 2025

Copy link
Copy Markdown
Member

@azat

azat commented Oct 13, 2025

Copy link
Copy Markdown
Member

@robot-ch-test-poll2 robot-ch-test-poll2 added pr-backports-created-cloud deprecated label, NOOP pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR labels Oct 13, 2025
azat added a commit that referenced this pull request Oct 13, 2025
Backport #87987 to 25.9: Fix index analysis with session_timezone specified
azat added a commit that referenced this pull request Oct 13, 2025
Backport #87987 to 25.8: Fix index analysis with session_timezone specified
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 13, 2025
azat added a commit that referenced this pull request Oct 14, 2025
Backport #87987 to 25.7: Fix index analysis with session_timezone specified
azat added a commit that referenced this pull request Oct 14, 2025
Backport #87987 to 25.3: Fix index analysis with session_timezone specified
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-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-backports-created-cloud deprecated label, NOOP pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Partition pruning does not consider session timezone correctly for datetime-based partition keys

5 participants