diff options
| author | azevaykin <[email protected]> | 2026-07-07 11:48:39 +0300 |
|---|---|---|
| committer | azevaykin <[email protected]> | 2026-07-07 12:26:27 +0300 |
| commit | 65fbcdc91d53bb48efff3bb41c23732b6c4b32fc (patch) | |
| tree | 386abfc1246cca980ba9f9df5c1cd55c47bff3d6 /yql/essentials/sql/v1/sql_query.cpp | |
| parent | 1540d7662ca2b227ab3fd14d6787ec662df0f31f (diff) | |
KIKIMR-25621: Introduce multi-column statistics
#### Introduce multi-column statistics support ✎
- Adds support for defining multi-column statistics in table schemas, allowing users to specify statistics for combinations of columns rather than individual columns
- Introduces new SQL syntax for CREATE TABLE and ALTER TABLE statements to declare statistics with optional type specifications
- Implements validation for statistics definitions, ensuring column references are valid and names are unique
- Extends the query processing pipeline to handle statistics declarations during table creation and modification operations
- Updates syntax highlighting and parsing rules to recognize the new statistics keyword and related constructs
- Adds comprehensive unit tests covering various statistics scenarios including multi-column definitions, type specifications, and validation rules
<a href="https://nda.ya.ru/t/qa0kX64r7DqvtN"><font size="2">Autodescription by Yandex Code Assistant</font></a>
commit_hash:5ca3f8721d3e3660f2bb890c1408e420cf7c3e81
Diffstat (limited to 'yql/essentials/sql/v1/sql_query.cpp')
| -rw-r--r-- | yql/essentials/sql/v1/sql_query.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/yql/essentials/sql/v1/sql_query.cpp b/yql/essentials/sql/v1/sql_query.cpp index 4983e961f60..45d2b5b79c2 100644 --- a/yql/essentials/sql/v1/sql_query.cpp +++ b/yql/essentials/sql/v1/sql_query.cpp @@ -2565,7 +2565,9 @@ bool TSqlQuery::AlterTableAction(const TRule_alter_table_action& node, TAlterTab case TRule_alter_table_action::kAltAlterTableAction10: { // DROP INDEX const auto& dropIndex = node.GetAlt_alter_table_action10().GetRule_alter_table_drop_index1(); - AlterTableDropIndex(dropIndex, params); + if (!AlterTableDropIndex(dropIndex, params)) { + return false; + } break; } case TRule_alter_table_action::kAltAlterTableAction11: { @@ -2692,6 +2694,22 @@ bool TSqlQuery::AlterTableAction(const TRule_alter_table_action& node, TAlterTab break; } + case TRule_alter_table_action::kAltAlterTableAction24: { + // ADD STATISTICS + const auto& addStatistics = node.GetAlt_alter_table_action24().GetRule_alter_table_add_statistics1(); + if (!AlterTableAddStatistics(addStatistics, params)) { + return false; + } + break; + } + case TRule_alter_table_action::kAltAlterTableAction25: { + // DROP STATISTICS + const auto& dropStatistics = node.GetAlt_alter_table_action25().GetRule_alter_table_drop_statistics1(); + if (!AlterTableDropStatistics(dropStatistics, params)) { + return false; + } + break; + } case TRule_alter_table_action::ALT_NOT_SET: YQL_ENSURE(false, "Unreachable"); } @@ -3025,8 +3043,18 @@ bool TSqlQuery::AlterTableAddIndex(const TRule_alter_table_add_index& node, TAlt return CreateTableIndex(node.GetRule_table_index2(), params.AddIndexes); } -void TSqlQuery::AlterTableDropIndex(const TRule_alter_table_drop_index& node, TAlterTableParameters& params) { +bool TSqlQuery::AlterTableDropIndex(const TRule_alter_table_drop_index& node, TAlterTableParameters& params) { params.DropIndexes.emplace_back(IdEx(node.GetRule_an_id3(), *this)); + return !Ctx_.HasPendingErrors; +} + +bool TSqlQuery::AlterTableAddStatistics(const TRule_alter_table_add_statistics& node, TAlterTableParameters& params) { + return CreateTableStatistics(node.GetRule_table_statistics2(), params.AddStatistics); +} + +bool TSqlQuery::AlterTableDropStatistics(const TRule_alter_table_drop_statistics& node, TAlterTableParameters& params) { + params.DropStatistics.emplace_back(IdEx(node.GetRule_an_id3(), *this)); + return !Ctx_.HasPendingErrors; } void TSqlQuery::AlterTableRenameTo(const TRule_alter_table_rename_to& node, TAlterTableParameters& params) { |
