Repository navigation
Conversation
fc121f4 to
9353bc7
Compare
8a2c36f to
a89cb5c
Compare
|
Dear @novikd, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message. |
|
Dear @novikd, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message. |
4 similar comments
|
Dear @novikd, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message. |
|
Dear @novikd, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message. |
|
Dear @novikd, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message. |
|
Dear @novikd, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message. |
…tions Resolves conflicts in 12 files after the branch was 14+ months stale (diverged 2025-02-19, ~61k commits behind). Adopts master's evolved APIs for `getProjectionFromAST`, `getMinMaxCountProjection`, the `Planner` constructor (which gained a `post_filter_` parameter and parallel replicas table-union support), and the `addExpressionStep`/`addFilterStep` templates that now thread `planner_context`, `select_query_options`, and `correlated_subtrees`. Master's `ProjectionsDescription` rewrite (`StorageProjectionSource`, two-phase analyze-then-execute, `_part_offset`/`_parent_part_offset` handling, `ProjectionDataSource`/`ProjectionDataSink`) supersedes the PR's earlier analyzer-driven metadata path, so the unused `buildMetadataAndFillProjectionKeys` helper added by the PR is dropped. The `optimizeUseAggregateProjection` analyzer branch from the PR is kept alongside master's non-analyzer fallback (which now uses `getSampleBlockWithSubcolumns`). `calculateByQuery` keeps both paths, with the analyzer branch using `TemporaryTableHolder` + `StorageValues` + `InterpreterSelectQueryAnalyzer` and the non-analyzer path using master's `ProjectionDataSource`. `AggregationAnalysisResult::aggregation_keys` is reverted to master's `Names` (the PR had switched it to `NamesAndTypes`); call sites in `Planner` and `optimizeUseAggregateProjection` follow. The `Planner` constructor merges both new parameters: `(query_tree_, select_query_options_, post_filter_ = nullptr, qualify_column_names = true)`. `qualify_column_names` flows into `GlobalPlannerContext` and `buildColumnIdentifier`.
|
Workflow [PR], commit [8b52951] Summary: ❌
AI ReviewSummaryThis PR switches projection analysis/calculation to analyzer-based paths in several places, but it currently has one correctness regression in Findings❌ Blockers
💡 Nits
Tests
ClickHouse Rules
Final VerdictStatus: Minimum required actions:
|
| result.partition_value_indices.push_back(result.sample_block.getPositionByName(key.name)); | ||
| } | ||
| result.sample_block_for_keys.insert({nullptr, key.type, key.name}); | ||
| result.partition_value_indices.push_back(result.sample_block.getPositionByName(key.name)); |
There was a problem hiding this comment.
result.sample_block.getPositionByName(key.name) now runs unconditionally, but result.sample_block has just had all constant columns removed (erase(constant_positions)). For partition keys like tuple() (common for non-partitioned MergeTree), the aggregation key is constant and won't exist in result.sample_block, so this throws during table initialization.
Please keep the previous presence check (or equivalent guard) before pushing partition_value_indices, e.g. only append the index when result.sample_block.has(key.name).
| #include <Planner/Utils.h> | ||
|
|
||
| #include <Core/Settings.h> | ||
| #include "Core/NamesAndTypes.h" |
There was a problem hiding this comment.
Style check is currently failing on this include because local headers in ClickHouse sources should use angle brackets.
Please change this to #include <Core/NamesAndTypes.h>.
|
|
||
| #include <Processors/QueryPlan/QueryPlan.h> | ||
| #include <Storages/SelectQueryInfo.h> | ||
| #include "Planner/PlannerExpressionAnalysis.h" |
There was a problem hiding this comment.
Style check is failing here for quoted include style.
Please switch this to #include <Planner/PlannerExpressionAnalysis.h>.
|
|
||
| #include <Interpreters/Context.h> | ||
| #include <Interpreters/QueryLog.h> | ||
| #include "Planner/PlannerContext.h" |
There was a problem hiding this comment.
Style check reports this include due to quotes.
Please use angle brackets: #include <Planner/PlannerContext.h>.
| #include <Interpreters/Context.h> | ||
| #include <Interpreters/QueryLog.h> | ||
| #include "Planner/PlannerContext.h" | ||
| #include "Planner/PlannerExpressionAnalysis.h" |
There was a problem hiding this comment.
Style check reports this include due to quotes.
Please use angle brackets: #include <Planner/PlannerExpressionAnalysis.h>.
|
|
||
| #include <Columns/ColumnAggregateFunction.h> | ||
| #include <Common/logger_useful.h> | ||
| #include "Storages/StorageValues.h" |
There was a problem hiding this comment.
Style check is failing on this line because quoted include syntax is not allowed here.
Please replace it with #include <Storages/StorageValues.h>.
| namespace | ||
| { | ||
|
|
||
| struct StorageSubstituionOptions |
There was a problem hiding this comment.
Typo: StorageSubstituionOptions should be StorageSubstitutionOptions.
Renaming avoids carrying the misspelling into future call sites and diagnostics.
|
Dear @novikd, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message. |
|
Duplicate of #96886 |
`ProjectionDescription::calculateByQuery` interpreted the `SELECT` of a projection with the legacy `InterpreterSelectQuery`. Use `InterpreterSelectQueryAnalyzer`. The columns of a projection part are named after the expressions of the projection query as they are written, because the projection metadata (`sample_block`) is derived from the AST. The Analyzer names the columns of a plan by its own rules - a column by the identifier of its table expression (`__table1.a`), a constant with its data type appended (`1_UInt8`), a set by its key - so the result of the pipeline is renamed back to the names of the metadata by mapping every expression of the query tree to the name its AST gives. Two more differences have to be reconciled: a `tuple` at the top level of `GROUP BY`, which the Analyzer unwraps into separate keys, and the `ORDER BY` expression, which `ASTProjectionSelectQuery::cloneToASTSelect` appends to the `SELECT` list and which may therefore duplicate a projection column. A column of the metadata missing from the result is now reported instead of being silently dropped by the part writer, which would write a projection part without that column and read it back as the default value of its type. The synthetic table expression which stands in for the missing `FROM` clause of a projection query borrows the name of `system.one`. The Analyzer plans a read from a table expression as a read from a table, so it checks the access rights and applies the quotas for it, and calculating a projection must not require anything beyond the rights of the query which writes the data. Related: ClickHouse#75728 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Use analyzer to calculate projections.
Documentation entry for user-facing changes