Skip to content

Fix some cases where secondary index was not applied with analyzer.#78485

Merged
KochetovNicolai merged 23 commits intomasterfrom
fix-some-secondary-index-for-analyzer
Apr 15, 2025
Merged

Fix some cases where secondary index was not applied with analyzer.#78485
KochetovNicolai merged 23 commits intomasterfrom
fix-some-secondary-index-for-analyzer

Conversation

@KochetovNicolai
Copy link
Copy Markdown
Member

@KochetovNicolai KochetovNicolai commented Mar 31, 2025

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 to CHANGELOG.md):

Fix some cases where secondary index was not applied with analyzer.
Fixes #65607 , fixes #69373

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Mar 31, 2025

Workflow [PR], commit [0c582bd]

@clickhouse-gh clickhouse-gh bot added the pr-bugfix Pull request with bugfix, not backported by default label Apr 1, 2025
@devcrafter devcrafter self-assigned this Apr 2, 2025
@KochetovNicolai KochetovNicolai added pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-cloud labels Apr 2, 2025

INSERT INTO t SELECT toString(number), number, toString(number) from numbers(65536);

explain indexes=1 select tenant,recordTimestamp from t where colAlias like '%abcd%' settings enable_analyzer=1;
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.

(1) should we add check w/o analyzer?
(2) also, it's better to output only part of explain related to indices


--- #69373

CREATE TABLE tab_v1
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.

drop table if exists ...


drop table ...

It's useful for running tests locally with default database

explain indexes=1 select tenant,recordTimestamp from t where colAlias like '%abcd%' settings enable_analyzer=1;


--- #69373
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.

Suggested change
--- #69373
-- #69373
select 'index is applied to view';

@@ -0,0 +1,45 @@
-- Tags: no-random-merge-tree-settings, no-random-settings, no-parallel-replicas

--- #65607
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.

Suggested change
--- #65607
-- #65607
select 'index is applied while using column alias';

/// Construct key condition from ActionsDAG nodes
KeyCondition(
const ActionsDAG * filter_dag,
const ActionsDAGWithInversionPushDown & filter_dag,
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.

Actually, we can construct ActionsDAGWithInversionPushDown inside KeyCondition constructor. context is already passed into KeyCondition as second parameter, just need to pass const ActionsDAG::Node * predicate_ as first parameter instead of const ActionsDAG * filter_dag. This way, we don't need to construct ActionsDAGWithInversionPushDown outside KeyCondition first.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The whole idea of adding the ActionsDAGWithInversionPushDown structure is to allow creating it outside of KeyCondition and make it reusable. We already did the same kind of work for PK and partition key, and now for secondary indexes too.

It's possible to keep an old ctor, but in this case it would be hard to check all the existing usages.

ConditionSelectivityEstimator estimator;
PartitionPruner partition_pruner(storage_snapshot->metadata, filter_dag, local_context);
ActionsDAGWithInversionPushDown inverted_dag(filter_dag->getOutputs().front(), local_context);
PartitionPruner partition_pruner(storage_snapshot->metadata, inverted_dag, local_context);
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.

Similar to KeyCondition, - ActionsDAGWithInversionPushDown can be constructed inside PartitionPruner

kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 9, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 10, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 11, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 12, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 13, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 14, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 15, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 16, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 17, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 18, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 19, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 20, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 21, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
Algunenano added a commit that referenced this pull request May 22, 2025
Backport #78485 to 25.4: Fix some cases where secondary index was not applied with analyzer.
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 22, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 23, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 24, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 25, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 26, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 27, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
baibaichen pushed a commit to Kyligence/ClickHouse that referenced this pull request May 29, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
baibaichen pushed a commit to Kyligence/ClickHouse that referenced this pull request May 29, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 29, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 30, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request May 31, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request Jun 1, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
kyligence-git pushed a commit to Kyligence/ClickHouse that referenced this pull request Jun 2, 2025
Fix rebase issue:
- 20250502 ClickHouse#79180
- 20250416 ClickHouse#78485
- 20250306 ClickHouse#76662

Co-authored-by: liuneng1994 <neng.liu@kyligence.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Analyzer: Skipping indexes don't work with VIEWs Different behavior of skip index with alias in latest version

6 participants