diff options
| author | vitya-smirnov <[email protected]> | 2025-10-07 09:34:39 +0300 |
|---|---|---|
| committer | vitya-smirnov <[email protected]> | 2025-10-07 09:52:14 +0300 |
| commit | babe7533f18c11be1f8a195ed2324d2d9a89436a (patch) | |
| tree | 45b7627141bf5a52b45a3d61fd1fbdd564bb8dd9 /yql/essentials/sql/v1/sql_query.cpp | |
| parent | 8fe7cfe254fde2772477a8933a163b5f303716b4 (diff) | |
YQL-20086 sql/v1
commit_hash:55bc611cdaa0d8a0fc3c4c7708ed9f17cc4976cf
Diffstat (limited to 'yql/essentials/sql/v1/sql_query.cpp')
| -rw-r--r-- | yql/essentials/sql/v1/sql_query.cpp | 836 |
1 files changed, 398 insertions, 438 deletions
diff --git a/yql/essentials/sql/v1/sql_query.cpp b/yql/essentials/sql/v1/sql_query.cpp index 3f31663f8b1..bb846e93012 100644 --- a/yql/essentials/sql/v1/sql_query.cpp +++ b/yql/essentials/sql/v1/sql_query.cpp @@ -11,7 +11,7 @@ #include <util/generic/scope.h> #include <util/string/join.h> #ifdef GetMessage -#undef GetMessage + #undef GetMessage #endif namespace NSQLTranslationV1 { @@ -23,7 +23,7 @@ using namespace NSQLv1Generated; void FillTargetList(TTranslation& ctx, const TRule_set_target_list& node, TVector<TString>& targetList) { targetList.push_back(ColumnNameAsSingleStr(ctx, node.GetRule_set_target2().GetRule_column_name1())); - for (auto& block: node.GetBlock3()) { + for (auto& block : node.GetBlock3()) { targetList.push_back(ColumnNameAsSingleStr(ctx, block.GetRule_set_target2().GetRule_column_name1())); } } @@ -45,7 +45,7 @@ void TSqlQuery::AddStatementToBlocks(TVector<TNodePtr>& blocks, TNodePtr node) { } static bool AsyncReplicationSettingsEntry(std::map<TString, TNodePtr>& out, - const TRule_replication_settings_entry& in, TSqlExpression& ctx, bool create) + const TRule_replication_settings_entry& in, TSqlExpression& ctx, bool create) { auto key = IdEx(in.GetRule_an_id1(), ctx); auto value = ctx.Build(in.GetRule_expr3()); @@ -117,7 +117,7 @@ static bool AsyncReplicationSettingsEntry(std::map<TString, TNodePtr>& out, } static bool AsyncReplicationSettings(std::map<TString, TNodePtr>& out, - const TRule_replication_settings& in, TSqlExpression& ctx, bool create) + const TRule_replication_settings& in, TSqlExpression& ctx, bool create) { if (!AsyncReplicationSettingsEntry(out, in.GetRule_replication_settings_entry1(), ctx, create)) { return false; @@ -133,7 +133,7 @@ static bool AsyncReplicationSettings(std::map<TString, TNodePtr>& out, } static bool AsyncReplicationTarget(std::vector<std::pair<TString, TString>>& out, TStringBuf prefixPath, - const TRule_replication_target& in, TTranslation& ctx) + const TRule_replication_target& in, TTranslation& ctx) { const TString remote = Id(in.GetRule_object_ref1().GetRule_id_or_at2(), ctx).second; const TString local = Id(in.GetRule_object_ref3().GetRule_id_or_at2(), ctx).second; @@ -142,14 +142,14 @@ static bool AsyncReplicationTarget(std::vector<std::pair<TString, TString>>& out } static bool AsyncReplicationAlterAction(std::map<TString, TNodePtr>& settings, - const TRule_alter_replication_action& in, TSqlExpression& ctx) + const TRule_alter_replication_action& in, TSqlExpression& ctx) { // TODO(ilnaz): support other actions return AsyncReplicationSettings(settings, in.GetRule_alter_replication_set_setting1().GetRule_replication_settings3(), ctx, false); } static bool TransferSettingsEntry(std::map<TString, TNodePtr>& out, - const TRule_transfer_settings_entry& in, TSqlExpression& ctx, bool create) + const TRule_transfer_settings_entry& in, TSqlExpression& ctx, bool create) { auto key = IdEx(in.GetRule_an_id1(), ctx); auto value = ctx.Build(in.GetRule_expr3()); @@ -211,7 +211,7 @@ static bool TransferSettingsEntry(std::map<TString, TNodePtr>& out, } static bool TransferSettings(std::map<TString, TNodePtr>& out, - const TRule_transfer_settings& in, TSqlExpression& ctx, bool create) + const TRule_transfer_settings& in, TSqlExpression& ctx, bool create) { if (!TransferSettingsEntry(out, in.GetRule_transfer_settings_entry1(), ctx, create)) { return false; @@ -232,14 +232,14 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& ParseStatementName(core, internalStatementName, humanStatementName); const auto& altCase = core.Alt_case(); if (Mode_ == NSQLTranslation::ESqlMode::LIMITED_VIEW && (altCase >= TRule_sql_stmt_core::kAltSqlStmtCore4 && - altCase != TRule_sql_stmt_core::kAltSqlStmtCore13 && altCase != TRule_sql_stmt_core::kAltSqlStmtCore18)) { + altCase != TRule_sql_stmt_core::kAltSqlStmtCore13 && altCase != TRule_sql_stmt_core::kAltSqlStmtCore18)) { Error() << humanStatementName << " statement is not supported in limited views"; return false; } if (Mode_ == NSQLTranslation::ESqlMode::SUBQUERY && (altCase >= TRule_sql_stmt_core::kAltSqlStmtCore4 && - altCase != TRule_sql_stmt_core::kAltSqlStmtCore13 && altCase != TRule_sql_stmt_core::kAltSqlStmtCore6 && - altCase != TRule_sql_stmt_core::kAltSqlStmtCore18)) { + altCase != TRule_sql_stmt_core::kAltSqlStmtCore13 && altCase != TRule_sql_stmt_core::kAltSqlStmtCore6 && + altCase != TRule_sql_stmt_core::kAltSqlStmtCore18)) { Error() << humanStatementName << " statement is not supported in subqueries"; return false; } @@ -274,8 +274,8 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& return false; } blocks.emplace_back(BuildSelectResult(pos, std::move(source), - Mode_ != NSQLTranslation::ESqlMode::LIMITED_VIEW && Mode_ != NSQLTranslation::ESqlMode::SUBQUERY, Mode_ == NSQLTranslation::ESqlMode::SUBQUERY, - Ctx_.Scoped)); + Mode_ != NSQLTranslation::ESqlMode::LIMITED_VIEW && Mode_ != NSQLTranslation::ESqlMode::SUBQUERY, Mode_ == NSQLTranslation::ESqlMode::SUBQUERY, + Ctx_.Scoped)); break; } case TRule_sql_stmt_core::kAltSqlStmtCore3: { @@ -295,7 +295,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& const auto alias = Ctx_.MakeName("subquerynode"); const auto ref = Ctx_.MakeName("subquery"); blocks.push_back(BuildSubquery(subquery, alias, - Mode_ == NSQLTranslation::ESqlMode::SUBQUERY, names.size() == 1 ? -1 : names.size(), Ctx_.Scoped)); + Mode_ == NSQLTranslation::ESqlMode::SUBQUERY, names.size() == 1 ? -1 : names.size(), Ctx_.Scoped)); blocks.back()->SetLabel(ref); for (size_t i = 0; i < names.size(); ++i) { @@ -337,8 +337,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& replaceIfExists = true; Y_DEBUG_ABORT_UNLESS( (IS_TOKEN(Ctx_.Settings.Antlr4Parser, rule.GetBlock2().GetToken1().GetId(), OR) && - IS_TOKEN(Ctx_.Settings.Antlr4Parser, rule.GetBlock2().GetToken2().GetId(), REPLACE)) - ); + IS_TOKEN(Ctx_.Settings.Antlr4Parser, rule.GetBlock2().GetToken2().GetId(), REPLACE))); } const bool isCreateTableAs = rule.HasBlock15(); @@ -346,8 +345,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& ETableType tableType = ETableType::Table; bool temporary = false; if (block.HasAlt2() && - IS_TOKEN(Ctx_.Settings.Antlr4Parser, block.GetAlt2().GetToken1().GetId(), TABLESTORE) - ) { + IS_TOKEN(Ctx_.Settings.Antlr4Parser, block.GetAlt2().GetToken1().GetId(), TABLESTORE)) { tableType = ETableType::TableStore; if (isCreateTableAs) { Context().Error(GetPos(block.GetAlt2().GetToken1())) @@ -355,8 +353,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& return false; } } else if (block.HasAlt3() && - IS_TOKEN(Ctx_.Settings.Antlr4Parser, block.GetAlt3().GetToken1().GetId(), EXTERNAL) - ) { + IS_TOKEN(Ctx_.Settings.Antlr4Parser, block.GetAlt3().GetToken1().GetId(), EXTERNAL)) { tableType = ETableType::ExternalTable; if (isCreateTableAs) { Context().Error(GetPos(block.GetAlt3().GetToken1())) @@ -374,8 +371,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& Y_DEBUG_ABORT_UNLESS( IS_TOKEN(Ctx_.Settings.Antlr4Parser, rule.GetBlock4().GetToken1().GetId(), IF) && IS_TOKEN(Ctx_.Settings.Antlr4Parser, rule.GetBlock4().GetToken2().GetId(), NOT) && - IS_TOKEN(Ctx_.Settings.Antlr4Parser, rule.GetBlock4().GetToken3().GetId(), EXISTS) - ); + IS_TOKEN(Ctx_.Settings.Antlr4Parser, rule.GetBlock4().GetToken3().GetId(), EXISTS)); } if (replaceIfExists && tableType != ETableType::ExternalTable) { @@ -389,11 +385,11 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& return false; } - TCreateTableParameters params{.TableType=tableType, .Temporary=temporary}; + TCreateTableParameters params{.TableType = tableType, .Temporary = temporary}; if (!CreateTableEntry(rule.GetRule_create_table_entry7(), params, isCreateTableAs)) { return false; } - for (auto& block: rule.GetBlock8()) { + for (auto& block : rule.GetBlock8()) { if (!CreateTableEntry(block.GetRule_create_table_entry2(), params, isCreateTableAs)) { return false; } @@ -462,8 +458,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& missingOk = true; Y_DEBUG_ABORT_UNLESS( IS_TOKEN(Ctx_.Settings.Antlr4Parser, rule.GetBlock3().GetToken1().GetId(), IF) && - IS_TOKEN(Ctx_.Settings.Antlr4Parser, rule.GetBlock3().GetToken2().GetId(), EXISTS) - ); + IS_TOKEN(Ctx_.Settings.Antlr4Parser, rule.GetBlock3().GetToken2().GetId(), EXISTS)); } TTableRef tr; @@ -665,8 +660,8 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& return false; } blocks.emplace_back(BuildSelectResult(pos, std::move(source), - Mode_ != NSQLTranslation::ESqlMode::LIMITED_VIEW && Mode_ != NSQLTranslation::ESqlMode::SUBQUERY, Mode_ == NSQLTranslation::ESqlMode::SUBQUERY, - Ctx_.Scoped)); + Mode_ != NSQLTranslation::ESqlMode::LIMITED_VIEW && Mode_ != NSQLTranslation::ESqlMode::SUBQUERY, Mode_ == NSQLTranslation::ESqlMode::SUBQUERY, + Ctx_.Scoped)); break; } case TRule_sql_stmt_core::kAltSqlStmtCore22: { @@ -890,8 +885,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& missingOk = true; Y_DEBUG_ABORT_UNLESS( IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock3().GetToken1().GetId(), IF) && - IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock3().GetToken2().GetId(), EXISTS) - ); + IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock3().GetToken2().GetId(), EXISTS)); } TVector<TDeferredAtom> roles; @@ -917,7 +911,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref4().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref4().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -928,8 +922,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& Y_DEBUG_ABORT_UNLESS( IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock3().GetToken1().GetId(), IF) && IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock3().GetToken2().GetId(), NOT) && - IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock3().GetToken3().GetId(), EXISTS) - ); + IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock3().GetToken3().GetId(), EXISTS)); } const TString& objectId = Id(node.GetRule_object_ref4().GetRule_id_or_at2(), *this).second; @@ -950,7 +943,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref3().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref3().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -971,7 +964,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref4().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref4().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -981,8 +974,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& missingOk = true; Y_DEBUG_ABORT_UNLESS( IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock3().GetToken1().GetId(), IF) && - IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock3().GetToken2().GetId(), EXISTS) - ); + IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock3().GetToken2().GetId(), EXISTS)); } const TString& objectId = Id(node.GetRule_object_ref4().GetRule_id_or_at2(), *this).second; @@ -1003,7 +995,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref7().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref7().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -1013,8 +1005,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& replaceIfExists = true; Y_DEBUG_ABORT_UNLESS( IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock2().GetToken1().GetId(), OR) && - IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock2().GetToken2().GetId(), REPLACE) - ); + IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock2().GetToken2().GetId(), REPLACE)); } bool existingOk = false; @@ -1023,8 +1014,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& Y_DEBUG_ABORT_UNLESS( IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock6().GetToken1().GetId(), IF) && IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock6().GetToken2().GetId(), NOT) && - IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock6().GetToken3().GetId(), EXISTS) - ); + IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock6().GetToken3().GetId(), EXISTS)); } const TString& objectId = Id(node.GetRule_object_ref7().GetRule_id_or_at2(), *this).second; @@ -1043,7 +1033,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref5().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref5().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -1070,7 +1060,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref6().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref6().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -1080,8 +1070,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& missingOk = true; Y_DEBUG_ABORT_UNLESS( IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock5().GetToken1().GetId(), IF) && - IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock5().GetToken2().GetId(), EXISTS) - ); + IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock5().GetToken2().GetId(), EXISTS)); } const TString& objectId = Id(node.GetRule_object_ref6().GetRule_id_or_at2(), *this).second; @@ -1119,7 +1108,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& const TString id = Id(node.GetRule_object_ref4().GetRule_id_or_at2(), *this).second; AddStatementToBlocks(blocks, BuildCreateAsyncReplication(Ctx_.Pos(), BuildTablePath(prefixPath, id), - std::move(targets), std::move(settings), context)); + std::move(targets), std::move(settings), context)); break; } case TRule_sql_stmt_core::kAltSqlStmtCore34: { @@ -1135,8 +1124,8 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& const TString id = Id(node.GetRule_object_ref4().GetRule_id_or_at2(), *this).second; AddStatementToBlocks(blocks, BuildDropAsyncReplication(Ctx_.Pos(), - BuildTablePath(Ctx_.GetPrefixPath(context.ServiceId, context.Cluster), id), - node.HasBlock5(), context)); + BuildTablePath(Ctx_.GetPrefixPath(context.ServiceId, context.Cluster), id), + node.HasBlock5(), context)); break; } case TRule_sql_stmt_core::kAltSqlStmtCore35: { @@ -1154,7 +1143,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TCreateTopicParameters params; params.ExistingOk = existingOk; - if (rule.HasBlock5()) { //create_topic_entry (consumers) + if (rule.HasBlock5()) { // create_topic_entry (consumers) auto& entries = rule.GetBlock5().GetRule_create_topic_entries1(); auto& firstEntry = entries.GetRule_create_topic_entry2(); if (!CreateTopicEntry(firstEntry, params)) { @@ -1166,7 +1155,6 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& return false; } } - } if (rule.HasBlock6()) { // with_topic_settings auto& topic_settings_node = rule.GetBlock6().GetRule_with_topic_settings1().GetRule_topic_settings3(); @@ -1177,8 +1165,8 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& break; } case TRule_sql_stmt_core::kAltSqlStmtCore36: { -// alter_topic_stmt: ALTER TOPIC topic_ref alter_topic_action (COMMA alter_topic_action)*; -// alter_topic_stmt: ALTER TOPIC IF EXISTS topic_ref alter_topic_action (COMMA alter_topic_action)*; + // alter_topic_stmt: ALTER TOPIC topic_ref alter_topic_action (COMMA alter_topic_action)*; + // alter_topic_stmt: ALTER TOPIC IF EXISTS topic_ref alter_topic_action (COMMA alter_topic_action)*; Ctx_.BodyPart(); auto& rule = core.GetAlt_sql_stmt_core36().GetRule_alter_topic_stmt1(); @@ -1268,8 +1256,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& AddStatementToBlocks(blocks, BuildGrantPermissions(pos, service, cluster, permissions, schemaPaths, roleNames, Ctx_.Scoped)); break; } - case TRule_sql_stmt_core::kAltSqlStmtCore39: - { + case TRule_sql_stmt_core::kAltSqlStmtCore39: { // REVOKE (GRANT OPTION FOR)? permission_name_target ON an_id_schema (COMMA an_id_schema)* FROM role_name (COMMA role_name)*; Ctx_.BodyPart(); auto& node = core.GetAlt_sql_stmt_core39().GetRule_revoke_permissions_stmt1(); @@ -1311,15 +1298,14 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& AddStatementToBlocks(blocks, BuildRevokePermissions(pos, service, cluster, permissions, schemaPaths, roleNames, Ctx_.Scoped)); break; } - case TRule_sql_stmt_core::kAltSqlStmtCore40: - { + case TRule_sql_stmt_core::kAltSqlStmtCore40: { // ALTER TABLESTORE object_ref alter_table_store_action (COMMA alter_table_store_action)*; auto& node = core.GetAlt_sql_stmt_core40().GetRule_alter_table_store_stmt1(); TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref3().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref3().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -1334,14 +1320,13 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& AddStatementToBlocks(blocks, BuildAlterObjectOperation(Ctx_.Pos(), objectId, typeId, false, std::move(kv), std::set<TString>(), context)); break; } - case TRule_sql_stmt_core::kAltSqlStmtCore41: - { + case TRule_sql_stmt_core::kAltSqlStmtCore41: { // create_object_stmt: UPSERT OBJECT name (TYPE type [WITH k=v,...]); auto& node = core.GetAlt_sql_stmt_core41().GetRule_upsert_object_stmt1(); TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref3().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref3().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -1445,8 +1430,8 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& const TString id = Id(node.GetRule_object_ref4().GetRule_id_or_at2(), *this).second; AddStatementToBlocks(blocks, BuildAlterAsyncReplication(Ctx_.Pos(), - BuildTablePath(Ctx_.GetPrefixPath(context.ServiceId, context.Cluster), id), - std::move(settings), context)); + BuildTablePath(Ctx_.GetPrefixPath(context.ServiceId, context.Cluster), id), + std::move(settings), context)); break; } case TRule_sql_stmt_core::kAltSqlStmtCore45: { @@ -1455,7 +1440,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref4().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref4().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -1476,7 +1461,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref4().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref4().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -1503,7 +1488,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref4().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref4().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -1527,26 +1512,26 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& std::map<TString, TDeferredAtom> kv; if (!ParseBackupCollectionSettings(kv, node.GetRule_backup_collection_settings6())) { - return false; + return false; } bool database = false; TVector<TDeferredAtom> tables; if (node.HasBlock3()) { - database = node.GetBlock3().GetRule_create_backup_collection_entries1().has_alt_create_backup_collection_entries1(); - if (node.GetBlock3().GetRule_create_backup_collection_entries1().has_alt_create_backup_collection_entries2()) { - if (!ParseBackupCollectionTables( - tables, - node - .GetBlock3() - .GetRule_create_backup_collection_entries1() - .alt_create_backup_collection_entries2() - .GetRule_create_backup_collection_entries_many1() - .GetRule_table_list2())) - { - return false; - } - } + database = node.GetBlock3().GetRule_create_backup_collection_entries1().has_alt_create_backup_collection_entries1(); + if (node.GetBlock3().GetRule_create_backup_collection_entries1().has_alt_create_backup_collection_entries2()) { + if (!ParseBackupCollectionTables( + tables, + node + .GetBlock3() + .GetRule_create_backup_collection_entries1() + .alt_create_backup_collection_entries2() + .GetRule_create_backup_collection_entries_many1() + .GetRule_table_list2())) + { + return false; + } + } } const TString& objectId = Id(node.GetRule_backup_collection2().GetRule_object_ref3().GetRule_id_or_at2(), *this).second; @@ -1554,11 +1539,11 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& BuildCreateBackupCollection(Ctx_.Pos(), TString(Ctx_.GetPrefixPath(context.ServiceId, context.Cluster)), objectId, - TCreateBackupCollectionParameters { - .Settings = std::move(kv), - .Database = database, - .Tables = tables, - .ExistingOk = false, + TCreateBackupCollectionParameters{ + .Settings = std::move(kv), + .Database = database, + .Tables = tables, + .ExistingOk = false, }, context)); break; @@ -1585,39 +1570,37 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TVector<TDeferredAtom> removeTables; switch (node.GetBlock3().Alt_case()) { - case TRule_alter_backup_collection_stmt_TBlock3::kAlt1: { - if (!ParseBackupCollectionSettings(kv, toReset, node.GetBlock3().GetAlt1().GetRule_alter_backup_collection_actions1())) { - return false; + case TRule_alter_backup_collection_stmt_TBlock3::kAlt1: { + if (!ParseBackupCollectionSettings(kv, toReset, node.GetBlock3().GetAlt1().GetRule_alter_backup_collection_actions1())) { + return false; + } + break; } - break; - } - case TRule_alter_backup_collection_stmt_TBlock3::kAlt2: { - if (!ParseBackupCollectionEntries( - addDatabase, - dropDatabase, - addTables, - removeTables, - node.GetBlock3().GetAlt2().GetRule_alter_backup_collection_entries1())) - { - return false; + case TRule_alter_backup_collection_stmt_TBlock3::kAlt2: { + if (!ParseBackupCollectionEntries( + addDatabase, + dropDatabase, + addTables, + removeTables, + node.GetBlock3().GetAlt2().GetRule_alter_backup_collection_entries1())) + { + return false; + } + break; } - break; - } - case TRule_alter_backup_collection_stmt_TBlock3::ALT_NOT_SET: {} // do nothing + case TRule_alter_backup_collection_stmt_TBlock3::ALT_NOT_SET: { + } // do nothing } - auto database = addDatabase ? - TAlterBackupCollectionParameters::EDatabase::Add : - dropDatabase ? - TAlterBackupCollectionParameters::EDatabase::Drop : - TAlterBackupCollectionParameters::EDatabase::Unchanged; + auto database = addDatabase ? TAlterBackupCollectionParameters::EDatabase::Add : dropDatabase ? TAlterBackupCollectionParameters::EDatabase::Drop + : TAlterBackupCollectionParameters::EDatabase::Unchanged; const TString& objectId = Id(node.GetRule_backup_collection2().GetRule_object_ref3().GetRule_id_or_at2(), *this).second; AddStatementToBlocks(blocks, BuildAlterBackupCollection(Ctx_.Pos(), TString(Ctx_.GetPrefixPath(context.ServiceId, context.Cluster)), objectId, - TAlterBackupCollectionParameters { + TAlterBackupCollectionParameters{ .Settings = std::move(kv), .SettingsToReset = std::move(toReset), .Database = database, @@ -1646,7 +1629,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& BuildDropBackupCollection(Ctx_.Pos(), TString(Ctx_.GetPrefixPath(context.ServiceId, context.Cluster)), objectId, - TDropBackupCollectionParameters { + TDropBackupCollectionParameters{ .MissingOk = false, }, context)); @@ -1670,7 +1653,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& if (columnsNode.HasRule_column_name1()) { columns.push_back(Id(columnsNode.GetRule_column_name1().GetRule_an_id2(), *this)); - for (const auto& columnNode: columnsNode.GetBlock2()) { + for (const auto& columnNode : columnsNode.GetBlock2()) { columns.push_back(Id(columnNode.GetRule_column_name2().GetRule_an_id2(), *this)); } } @@ -1691,7 +1674,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref5().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref5().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -1712,7 +1695,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref5().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref5().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -1739,7 +1722,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref5().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref5().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -1754,7 +1737,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref2().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref2().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -1779,7 +1762,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref2().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref2().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -1824,7 +1807,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& if (node.GetRule_object_ref4().HasBlock1()) { if (!ClusterExpr(node.GetRule_object_ref4().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster)) { + false, context.ServiceId, context.Cluster)) { return false; } } @@ -1837,8 +1820,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& params.MissingOk = true; Y_DEBUG_ABORT_UNLESS( IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock3().GetToken1().GetId(), IF) && - IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock3().GetToken2().GetId(), EXISTS) - ); + IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock3().GetToken2().GetId(), EXISTS)); } for (const auto& block : node.GetBlock5()) { @@ -1850,7 +1832,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& AddStatementToBlocks(blocks, BuildAlterSequence(pos, service, cluster, id, params, Ctx_.Scoped)); break; } - case TRule_sql_stmt_core::kAltSqlStmtCore58: { + case TRule_sql_stmt_core::kAltSqlStmtCore58: { // create_transfer_stmt: CREATE TRANSFER auto& node = core.GetAlt_sql_stmt_core58().GetRule_create_transfer_stmt1(); @@ -1879,7 +1861,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& } AddStatementToBlocks(blocks, BuildCreateTransfer(Ctx_.Pos(), BuildTablePath(prefixPath, id), - std::move(source), std::move(target), std::move(transformLambda), std::move(settings), context)); + std::move(source), std::move(target), std::move(transformLambda), std::move(settings), context)); break; } case TRule_sql_stmt_core::kAltSqlStmtCore59: { @@ -1924,8 +1906,8 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& const TString id = Id(node.GetRule_object_ref3().GetRule_id_or_at2(), *this).second; AddStatementToBlocks(blocks, BuildAlterTransfer(Ctx_.Pos(), - BuildTablePath(Ctx_.GetPrefixPath(context.ServiceId, context.Cluster), id), - std::move(transformLambda), std::move(settings), context)); + BuildTablePath(Ctx_.GetPrefixPath(context.ServiceId, context.Cluster), id), + std::move(transformLambda), std::move(settings), context)); break; } case TRule_sql_stmt_core::kAltSqlStmtCore60: { @@ -1941,8 +1923,8 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& const TString id = Id(node.GetRule_object_ref3().GetRule_id_or_at2(), *this).second; AddStatementToBlocks(blocks, BuildDropTransfer(Ctx_.Pos(), - BuildTablePath(Ctx_.GetPrefixPath(context.ServiceId, context.Cluster), id), - node.HasBlock4(), context)); + BuildTablePath(Ctx_.GetPrefixPath(context.ServiceId, context.Cluster), id), + node.HasBlock4(), context)); break; } case TRule_sql_stmt_core::kAltSqlStmtCore61: { @@ -2029,8 +2011,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& if (replaceIfExists) { Y_DEBUG_ABORT_UNLESS( IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock2().GetToken1().GetId(), OR) && - IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock2().GetToken2().GetId(), REPLACE) - ); + IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock2().GetToken2().GetId(), REPLACE)); } // IF NOT EXISTS @@ -2039,8 +2020,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& Y_DEBUG_ABORT_UNLESS( IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock5().GetToken1().GetId(), IF) && IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock5().GetToken2().GetId(), NOT) && - IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock5().GetToken3().GetId(), EXISTS) - ); + IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock5().GetToken3().GetId(), EXISTS)); } // WITH streaming_query_settings @@ -2080,8 +2060,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& if (missingOk) { Y_DEBUG_ABORT_UNLESS( IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock4().GetToken1().GetId(), IF) && - IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock4().GetToken2().GetId(), EXISTS) - ); + IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock4().GetToken2().GetId(), EXISTS)); } // alter_streaming_query_action @@ -2110,8 +2089,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& if (missingOk) { Y_DEBUG_ABORT_UNLESS( IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock4().GetToken1().GetId(), IF) && - IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock4().GetToken2().GetId(), EXISTS) - ); + IS_TOKEN(Ctx_.Settings.Antlr4Parser, node.GetBlock4().GetToken2().GetId(), EXISTS)); } AddStatementToBlocks(blocks, BuildDropObjectOperation(Ctx_.Pos(), *objectPath, "STREAMING_QUERY", missingOk, {}, context)); @@ -2126,9 +2104,8 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref3().HasBlock1()) { if (!ClusterExpr( - node.GetRule_object_ref3().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster - )) { + node.GetRule_object_ref3().GetBlock1().GetRule_cluster_expr1(), + false, context.ServiceId, context.Cluster)) { return false; } } @@ -2154,8 +2131,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& BuildTablePath(Ctx_.GetPrefixPath(context.ServiceId, context.Cluster), objectId), secretParams, context, - Ctx_.Scoped) - ); + Ctx_.Scoped)); break; } case TRule_sql_stmt_core::kAltSqlStmtCore67: { @@ -2167,9 +2143,8 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref3().HasBlock1()) { if (!ClusterExpr( - node.GetRule_object_ref3().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster - )) { + node.GetRule_object_ref3().GetBlock1().GetRule_cluster_expr1(), + false, context.ServiceId, context.Cluster)) { return false; } } @@ -2195,8 +2170,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& BuildTablePath(Ctx_.GetPrefixPath(context.ServiceId, context.Cluster), objectId), secretParams, context, - Ctx_.Scoped) - ); + Ctx_.Scoped)); break; } case TRule_sql_stmt_core::kAltSqlStmtCore68: { @@ -2208,9 +2182,8 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& TObjectOperatorContext context(Ctx_.Scoped); if (node.GetRule_object_ref3().HasBlock1()) { if (!ClusterExpr( - node.GetRule_object_ref3().GetBlock1().GetRule_cluster_expr1(), - false, context.ServiceId, context.Cluster - )) { + node.GetRule_object_ref3().GetBlock1().GetRule_cluster_expr1(), + false, context.ServiceId, context.Cluster)) { return false; } } @@ -2226,8 +2199,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core& Ctx_.Pos(), BuildTablePath(Ctx_.GetPrefixPath(context.ServiceId, context.Cluster), objectId), context, - Ctx_.Scoped) - ); + Ctx_.Scoped)); break; } case TRule_sql_stmt_core::ALT_NOT_SET: @@ -2279,8 +2251,8 @@ bool TSqlQuery::DeclareStatement(const TRule_declare_stmt& stmt) { if (Ctx_.IsAlreadyDeclared(varName)) { if (!Ctx_.Warning(varPos, TIssuesIds::YQL_DUPLICATE_DECLARE, [&](auto& out) { - out << "Duplicate declaration of '" << varName << "' will be ignored"; - })) { + out << "Duplicate declaration of '" << varName << "' will be ignored"; + })) { return false; } } else { @@ -2317,164 +2289,163 @@ bool TSqlQuery::AlterTableAction(const TRule_alter_table_action& node, TAlterTab } switch (node.Alt_case()) { - case TRule_alter_table_action::kAltAlterTableAction1: { - // ADD COLUMN - const auto& addRule = node.GetAlt_alter_table_action1().GetRule_alter_table_add_column1(); - if (!AlterTableAddColumn(addRule, params)) { - return false; + case TRule_alter_table_action::kAltAlterTableAction1: { + // ADD COLUMN + const auto& addRule = node.GetAlt_alter_table_action1().GetRule_alter_table_add_column1(); + if (!AlterTableAddColumn(addRule, params)) { + return false; + } + break; } - break; - } - case TRule_alter_table_action::kAltAlterTableAction2: { - // DROP COLUMN - const auto& dropRule = node.GetAlt_alter_table_action2().GetRule_alter_table_drop_column1(); - if (!AlterTableDropColumn(dropRule, params)) { - return false; + case TRule_alter_table_action::kAltAlterTableAction2: { + // DROP COLUMN + const auto& dropRule = node.GetAlt_alter_table_action2().GetRule_alter_table_drop_column1(); + if (!AlterTableDropColumn(dropRule, params)) { + return false; + } + break; } - break; - } - case TRule_alter_table_action::kAltAlterTableAction3: { - // ALTER COLUMN - const auto& alterRule = node.GetAlt_alter_table_action3().GetRule_alter_table_alter_column1(); - if (!AlterTableAlterColumn(alterRule, params)) { - return false; + case TRule_alter_table_action::kAltAlterTableAction3: { + // ALTER COLUMN + const auto& alterRule = node.GetAlt_alter_table_action3().GetRule_alter_table_alter_column1(); + if (!AlterTableAlterColumn(alterRule, params)) { + return false; + } + break; } - break; - } - case TRule_alter_table_action::kAltAlterTableAction4: { - // ADD FAMILY - const auto& familyEntry = node.GetAlt_alter_table_action4().GetRule_alter_table_add_column_family1() - .GetRule_family_entry2(); - if (!AlterTableAddFamily(familyEntry, params)) { - return false; + case TRule_alter_table_action::kAltAlterTableAction4: { + // ADD FAMILY + const auto& familyEntry = node.GetAlt_alter_table_action4().GetRule_alter_table_add_column_family1().GetRule_family_entry2(); + if (!AlterTableAddFamily(familyEntry, params)) { + return false; + } + break; } - break; - } - case TRule_alter_table_action::kAltAlterTableAction5: { - // ALTER FAMILY - const auto& alterRule = node.GetAlt_alter_table_action5().GetRule_alter_table_alter_column_family1(); - if (!AlterTableAlterFamily(alterRule, params)) { - return false; + case TRule_alter_table_action::kAltAlterTableAction5: { + // ALTER FAMILY + const auto& alterRule = node.GetAlt_alter_table_action5().GetRule_alter_table_alter_column_family1(); + if (!AlterTableAlterFamily(alterRule, params)) { + return false; + } + break; } - break; - } - case TRule_alter_table_action::kAltAlterTableAction6: { - // SET (uncompat) - const auto& setRule = node.GetAlt_alter_table_action6().GetRule_alter_table_set_table_setting_uncompat1(); - if (!AlterTableSetTableSetting(setRule, params.TableSettings, params.TableType)) { - return false; + case TRule_alter_table_action::kAltAlterTableAction6: { + // SET (uncompat) + const auto& setRule = node.GetAlt_alter_table_action6().GetRule_alter_table_set_table_setting_uncompat1(); + if (!AlterTableSetTableSetting(setRule, params.TableSettings, params.TableType)) { + return false; + } + break; } - break; - } - case TRule_alter_table_action::kAltAlterTableAction7: { - // SET (compat) - const auto& setRule = node.GetAlt_alter_table_action7().GetRule_alter_table_set_table_setting_compat1(); - if (!AlterTableSetTableSetting(setRule, params.TableSettings, params.TableType)) { - return false; + case TRule_alter_table_action::kAltAlterTableAction7: { + // SET (compat) + const auto& setRule = node.GetAlt_alter_table_action7().GetRule_alter_table_set_table_setting_compat1(); + if (!AlterTableSetTableSetting(setRule, params.TableSettings, params.TableType)) { + return false; + } + break; } - break; - } - case TRule_alter_table_action::kAltAlterTableAction8: { - // RESET - const auto& setRule = node.GetAlt_alter_table_action8().GetRule_alter_table_reset_table_setting1(); - if (!AlterTableResetTableSetting(setRule, params.TableSettings, params.TableType)) { - return false; + case TRule_alter_table_action::kAltAlterTableAction8: { + // RESET + const auto& setRule = node.GetAlt_alter_table_action8().GetRule_alter_table_reset_table_setting1(); + if (!AlterTableResetTableSetting(setRule, params.TableSettings, params.TableType)) { + return false; + } + break; } - break; - } - case TRule_alter_table_action::kAltAlterTableAction9: { - // ADD INDEX - const auto& addIndex = node.GetAlt_alter_table_action9().GetRule_alter_table_add_index1(); - if (!AlterTableAddIndex(addIndex, params)) { - return false; + case TRule_alter_table_action::kAltAlterTableAction9: { + // ADD INDEX + const auto& addIndex = node.GetAlt_alter_table_action9().GetRule_alter_table_add_index1(); + if (!AlterTableAddIndex(addIndex, params)) { + return false; + } + break; } - break; - } - case TRule_alter_table_action::kAltAlterTableAction10: { - // DROP INDEX - const auto& dropIndex = node.GetAlt_alter_table_action10().GetRule_alter_table_drop_index1(); - AlterTableDropIndex(dropIndex, params); - break; - } - case TRule_alter_table_action::kAltAlterTableAction11: { - // RENAME TO - if (!params.IsEmpty()) { - // rename action follows some other actions - Error() << "RENAME TO can not be used together with another table action"; - return false; + case TRule_alter_table_action::kAltAlterTableAction10: { + // DROP INDEX + const auto& dropIndex = node.GetAlt_alter_table_action10().GetRule_alter_table_drop_index1(); + AlterTableDropIndex(dropIndex, params); + break; } + case TRule_alter_table_action::kAltAlterTableAction11: { + // RENAME TO + if (!params.IsEmpty()) { + // rename action follows some other actions + Error() << "RENAME TO can not be used together with another table action"; + return false; + } - const auto& renameTo = node.GetAlt_alter_table_action11().GetRule_alter_table_rename_to1(); - AlterTableRenameTo(renameTo, params); - break; - } - case TRule_alter_table_action::kAltAlterTableAction12: { - // ADD CHANGEFEED - const auto& rule = node.GetAlt_alter_table_action12().GetRule_alter_table_add_changefeed1(); - if (!AlterTableAddChangefeed(rule, params)) { - return false; + const auto& renameTo = node.GetAlt_alter_table_action11().GetRule_alter_table_rename_to1(); + AlterTableRenameTo(renameTo, params); + break; } - break; - } - case TRule_alter_table_action::kAltAlterTableAction13: { - // ALTER CHANGEFEED - const auto& rule = node.GetAlt_alter_table_action13().GetRule_alter_table_alter_changefeed1(); - if (!AlterTableAlterChangefeed(rule, params)) { - return false; + case TRule_alter_table_action::kAltAlterTableAction12: { + // ADD CHANGEFEED + const auto& rule = node.GetAlt_alter_table_action12().GetRule_alter_table_add_changefeed1(); + if (!AlterTableAddChangefeed(rule, params)) { + return false; + } + break; } - break; - } - case TRule_alter_table_action::kAltAlterTableAction14: { - // DROP CHANGEFEED - const auto& rule = node.GetAlt_alter_table_action14().GetRule_alter_table_drop_changefeed1(); - AlterTableDropChangefeed(rule, params); - break; - } - case TRule_alter_table_action::kAltAlterTableAction15: { - // RENAME INDEX TO - if (!params.IsEmpty()) { - // rename action follows some other actions - Error() << "RENAME INDEX TO can not be used together with another table action"; - return false; + case TRule_alter_table_action::kAltAlterTableAction13: { + // ALTER CHANGEFEED + const auto& rule = node.GetAlt_alter_table_action13().GetRule_alter_table_alter_changefeed1(); + if (!AlterTableAlterChangefeed(rule, params)) { + return false; + } + break; } - - const auto& renameTo = node.GetAlt_alter_table_action15().GetRule_alter_table_rename_index_to1(); - AlterTableRenameIndexTo(renameTo, params); - break; - } - case TRule_alter_table_action::kAltAlterTableAction16: { - // ALTER INDEX - const auto& rule = node.GetAlt_alter_table_action16().GetRule_alter_table_alter_index1(); - if (!AlterTableAlterIndex(rule, params)) { - return false; + case TRule_alter_table_action::kAltAlterTableAction14: { + // DROP CHANGEFEED + const auto& rule = node.GetAlt_alter_table_action14().GetRule_alter_table_drop_changefeed1(); + AlterTableDropChangefeed(rule, params); + break; } - break; - } - case TRule_alter_table_action::kAltAlterTableAction17: { - // ALTER COLUMN id DROP NOT NULL - const auto& alterRule = node.GetAlt_alter_table_action17().GetRule_alter_table_alter_column_drop_not_null1(); + case TRule_alter_table_action::kAltAlterTableAction15: { + // RENAME INDEX TO + if (!params.IsEmpty()) { + // rename action follows some other actions + Error() << "RENAME INDEX TO can not be used together with another table action"; + return false; + } - if (!AlterTableAlterColumnDropNotNull(alterRule, params)) { - return false; + const auto& renameTo = node.GetAlt_alter_table_action15().GetRule_alter_table_rename_index_to1(); + AlterTableRenameIndexTo(renameTo, params); + break; + } + case TRule_alter_table_action::kAltAlterTableAction16: { + // ALTER INDEX + const auto& rule = node.GetAlt_alter_table_action16().GetRule_alter_table_alter_index1(); + if (!AlterTableAlterIndex(rule, params)) { + return false; + } + break; } + case TRule_alter_table_action::kAltAlterTableAction17: { + // ALTER COLUMN id DROP NOT NULL + const auto& alterRule = node.GetAlt_alter_table_action17().GetRule_alter_table_alter_column_drop_not_null1(); - break; - } - case TRule_alter_table_action::kAltAlterTableAction18: { - // ALTER COLUMN id SET NOT NULL - const auto& alterRule = node.GetAlt_alter_table_action18().GetRule_alter_table_alter_column_set_not_null1(); + if (!AlterTableAlterColumnDropNotNull(alterRule, params)) { + return false; + } - if (!AlterTableAlterColumnSetNotNull(alterRule, params)) { - return false; + break; } + case TRule_alter_table_action::kAltAlterTableAction18: { + // ALTER COLUMN id SET NOT NULL + const auto& alterRule = node.GetAlt_alter_table_action18().GetRule_alter_table_alter_column_set_not_null1(); - break; - } + if (!AlterTableAlterColumnSetNotNull(alterRule, params)) { + return false; + } - case TRule_alter_table_action::ALT_NOT_SET: { - AltNotImplemented("alter_table_action", node); - return false; - } + break; + } + + case TRule_alter_table_action::ALT_NOT_SET: { + AltNotImplemented("alter_table_action", node); + return false; + } } return true; } @@ -2487,50 +2458,50 @@ bool TSqlQuery::AlterExternalTableAction(const TRule_alter_external_table_action } switch (node.Alt_case()) { - case TRule_alter_external_table_action::kAltAlterExternalTableAction1: { - // ADD COLUMN - const auto& addRule = node.GetAlt_alter_external_table_action1().GetRule_alter_table_add_column1(); - if (!AlterTableAddColumn(addRule, params)) { - return false; + case TRule_alter_external_table_action::kAltAlterExternalTableAction1: { + // ADD COLUMN + const auto& addRule = node.GetAlt_alter_external_table_action1().GetRule_alter_table_add_column1(); + if (!AlterTableAddColumn(addRule, params)) { + return false; + } + break; } - break; - } - case TRule_alter_external_table_action::kAltAlterExternalTableAction2: { - // DROP COLUMN - const auto& dropRule = node.GetAlt_alter_external_table_action2().GetRule_alter_table_drop_column1(); - if (!AlterTableDropColumn(dropRule, params)) { - return false; + case TRule_alter_external_table_action::kAltAlterExternalTableAction2: { + // DROP COLUMN + const auto& dropRule = node.GetAlt_alter_external_table_action2().GetRule_alter_table_drop_column1(); + if (!AlterTableDropColumn(dropRule, params)) { + return false; + } + break; } - break; - } - case TRule_alter_external_table_action::kAltAlterExternalTableAction3: { - // SET (uncompat) - const auto& setRule = node.GetAlt_alter_external_table_action3().GetRule_alter_table_set_table_setting_uncompat1(); - if (!AlterTableSetTableSetting(setRule, params.TableSettings, params.TableType)) { - return false; + case TRule_alter_external_table_action::kAltAlterExternalTableAction3: { + // SET (uncompat) + const auto& setRule = node.GetAlt_alter_external_table_action3().GetRule_alter_table_set_table_setting_uncompat1(); + if (!AlterTableSetTableSetting(setRule, params.TableSettings, params.TableType)) { + return false; + } + break; } - break; - } - case TRule_alter_external_table_action::kAltAlterExternalTableAction4: { - // SET (compat) - const auto& setRule = node.GetAlt_alter_external_table_action4().GetRule_alter_table_set_table_setting_compat1(); - if (!AlterTableSetTableSetting(setRule, params.TableSettings, params.TableType)) { - return false; + case TRule_alter_external_table_action::kAltAlterExternalTableAction4: { + // SET (compat) + const auto& setRule = node.GetAlt_alter_external_table_action4().GetRule_alter_table_set_table_setting_compat1(); + if (!AlterTableSetTableSetting(setRule, params.TableSettings, params.TableType)) { + return false; + } + break; } - break; - } - case TRule_alter_external_table_action::kAltAlterExternalTableAction5: { - // RESET - const auto& setRule = node.GetAlt_alter_external_table_action5().GetRule_alter_table_reset_table_setting1(); - if (!AlterTableResetTableSetting(setRule, params.TableSettings, params.TableType)) { - return false; + case TRule_alter_external_table_action::kAltAlterExternalTableAction5: { + // RESET + const auto& setRule = node.GetAlt_alter_external_table_action5().GetRule_alter_table_reset_table_setting1(); + if (!AlterTableResetTableSetting(setRule, params.TableSettings, params.TableType)) { + return false; + } + break; } - break; - } - case TRule_alter_external_table_action::ALT_NOT_SET: - AltNotImplemented("alter_external_table_action", node); - return false; + case TRule_alter_external_table_action::ALT_NOT_SET: + AltNotImplemented("alter_external_table_action", node); + return false; } return true; } @@ -2555,7 +2526,7 @@ bool TSqlQuery::AlterTableDropColumn(const TRule_alter_table_drop_column& node, } bool TSqlQuery::AlterTableAlterColumn(const TRule_alter_table_alter_column& node, - TAlterTableParameters& params) + TAlterTableParameters& params) { TString name = Id(node.GetRule_an_id3(), *this); const TPosition pos(Context().Pos()); @@ -2576,7 +2547,7 @@ bool TSqlQuery::AlterTableAddFamily(const TRule_family_entry& node, TAlterTableP } bool TSqlQuery::AlterTableAlterFamily(const TRule_alter_table_alter_column_family& node, - TAlterTableParameters& params) + TAlterTableParameters& params) { TFamilyEntry* entry = nullptr; TIdentifier name = IdEx(node.GetRule_an_id3(), *this); @@ -2594,7 +2565,7 @@ bool TSqlQuery::AlterTableAlterFamily(const TRule_alter_table_alter_column_famil if (to_lower(settingName.Name) == "data") { if (entry->Data) { Ctx_.Error() << "Redefinition of " << to_upper(settingName.Name) << " setting for column family '" << name.Name - << "' in one alter"; + << "' in one alter"; return false; } if (!StoreString(value, entry->Data, Ctx_)) { @@ -2604,7 +2575,7 @@ bool TSqlQuery::AlterTableAlterFamily(const TRule_alter_table_alter_column_famil } else if (to_lower(settingName.Name) == "compression") { if (entry->Compression) { Ctx_.Error() << "Redefinition of " << to_upper(settingName.Name) << " setting for column family '" << name.Name - << "' in one alter"; + << "' in one alter"; return false; } if (!StoreString(value, entry->Compression, Ctx_)) { @@ -2623,7 +2594,7 @@ bool TSqlQuery::AlterTableAlterFamily(const TRule_alter_table_alter_column_famil } else if (to_lower(settingName.Name) == "cache_mode") { if (entry->CacheMode) { Ctx_.Error() << "Redefinition of " << to_upper(settingName.Name) << " setting for column family '" << name.Name - << "' in one alter"; + << "' in one alter"; return false; } if (!StoreString(value, entry->CacheMode, Ctx_)) { @@ -2638,28 +2609,24 @@ bool TSqlQuery::AlterTableAlterFamily(const TRule_alter_table_alter_column_famil } bool TSqlQuery::AlterTableSetTableSetting( - const TRule_alter_table_set_table_setting_uncompat& node, TTableSettings& tableSettings, ETableType tableType -) { + const TRule_alter_table_set_table_setting_uncompat& node, TTableSettings& tableSettings, ETableType tableType) { return StoreTableSettingsEntry( IdEx(node.GetRule_an_id2(), *this), node.GetRule_table_setting_value3(), tableSettings, tableType, - true - ); + true); } bool TSqlQuery::AlterTableSetTableSetting( - const TRule_alter_table_set_table_setting_compat& node, TTableSettings& tableSettings, ETableType tableType -) { + const TRule_alter_table_set_table_setting_compat& node, TTableSettings& tableSettings, ETableType tableType) { const auto storeSetting = [&](const TRule_alter_table_setting_entry& entry) { return StoreTableSettingsEntry( IdEx(entry.GetRule_an_id1(), *this), entry.GetRule_table_setting_value3(), tableSettings, tableType, - true - ); + true); }; const auto& firstEntry = node.GetRule_alter_table_setting_entry3(); @@ -2676,8 +2643,7 @@ bool TSqlQuery::AlterTableSetTableSetting( } bool TSqlQuery::AlterTableResetTableSetting( - const TRule_alter_table_reset_table_setting& node, TTableSettings& tableSettings, ETableType tableType -) { + const TRule_alter_table_reset_table_setting& node, TTableSettings& tableSettings, ETableType tableType) { const auto resetSetting = [&](const TRule_an_id& id) { return ResetTableSettingsEntry(IdEx(id, *this), tableSettings, tableType); }; @@ -2725,33 +2691,33 @@ bool TSqlQuery::AlterTableAlterIndex(const TRule_alter_table_alter_index& node, const auto& action = node.GetRule_alter_table_alter_index_action4(); switch (action.Alt_case()) { - case TRule_alter_table_alter_index_action::kAltAlterTableAlterIndexAction1: { - // SET setting value - const auto& rule = action.GetAlt_alter_table_alter_index_action1().GetRule_alter_table_set_table_setting_uncompat1(); - if (!AlterTableSetTableSetting(rule, indexTableSettings, params.TableType)) { - return false; + case TRule_alter_table_alter_index_action::kAltAlterTableAlterIndexAction1: { + // SET setting value + const auto& rule = action.GetAlt_alter_table_alter_index_action1().GetRule_alter_table_set_table_setting_uncompat1(); + if (!AlterTableSetTableSetting(rule, indexTableSettings, params.TableType)) { + return false; + } + break; } - break; - } - case TRule_alter_table_alter_index_action::kAltAlterTableAlterIndexAction2: { - // SET (setting1 = value1, ...) - const auto& rule = action.GetAlt_alter_table_alter_index_action2().GetRule_alter_table_set_table_setting_compat1(); - if (!AlterTableSetTableSetting(rule, indexTableSettings, params.TableType)) { - return false; + case TRule_alter_table_alter_index_action::kAltAlterTableAlterIndexAction2: { + // SET (setting1 = value1, ...) + const auto& rule = action.GetAlt_alter_table_alter_index_action2().GetRule_alter_table_set_table_setting_compat1(); + if (!AlterTableSetTableSetting(rule, indexTableSettings, params.TableType)) { + return false; + } + break; } - break; - } - case TRule_alter_table_alter_index_action::kAltAlterTableAlterIndexAction3: { - // RESET (setting1, ...) - const auto& rule = action.GetAlt_alter_table_alter_index_action3().GetRule_alter_table_reset_table_setting1(); - if (!AlterTableResetTableSetting(rule, indexTableSettings, params.TableType)) { - return false; + case TRule_alter_table_alter_index_action::kAltAlterTableAlterIndexAction3: { + // RESET (setting1, ...) + const auto& rule = action.GetAlt_alter_table_alter_index_action3().GetRule_alter_table_reset_table_setting1(); + if (!AlterTableResetTableSetting(rule, indexTableSettings, params.TableType)) { + return false; + } + break; } - break; - } - case TRule_alter_table_alter_index_action::ALT_NOT_SET: - AltNotImplemented("alter_table_alter_index_action", action); - return false; + case TRule_alter_table_alter_index_action::ALT_NOT_SET: + AltNotImplemented("alter_table_alter_index_action", action); + return false; } return true; @@ -2866,7 +2832,7 @@ void TSqlQuery::AlterTableDropChangefeed(const TRule_alter_table_drop_changefeed } namespace { -#define CB_SIG TVector<TDeferredAtom>& values [[maybe_unused]], bool pragmaValueDefault [[maybe_unused]], TStringBuf pragma [[maybe_unused]], TSqlQuery& query [[maybe_unused]] +#define CB_SIG TVector<TDeferredAtom>&values [[maybe_unused]], bool pragmaValueDefault [[maybe_unused]], TStringBuf pragma [[maybe_unused]], TSqlQuery &query [[maybe_unused]] using PragmaStatementCb = std::function<TMaybe<TNodePtr>(CB_SIG)>; @@ -2875,8 +2841,10 @@ struct TPragmaDescr { PragmaStatementCb Cb; }; -template<typename T, std::convertible_to<T> U> -PragmaStatementCb SetCtxField(T TContext::* ParamPtr, U ParamValue) requires std::movable<U> { +template <typename T, std::convertible_to<T> U> +PragmaStatementCb SetCtxField(T TContext::*ParamPtr, U ParamValue) + requires std::movable<U> +{ return [ParamPtr, ParamValue = std::move(ParamValue)](CB_SIG) { auto& Ctx_ = query.Context(); Ctx_.*ParamPtr = std::move(ParamValue); @@ -3237,8 +3205,8 @@ THashMap<TString, TPragmaDescr> PragmaDescrs{ return {}; } if (!ctx.Warning(ctx.Pos(), TIssuesIds::YQL_PRAGMA_WARNING_MSG, [&](auto& out) { - out << *values[0].GetLiteral(); - })) { + out << *values[0].GetLiteral(); + })) { return {}; } return TNodePtr{}; @@ -3271,8 +3239,8 @@ THashMap<TString, TPragmaDescr> PragmaDescrs{ TableElemExt("DisableUnordered", [](CB_SIG) -> TMaybe<TNodePtr> { auto& ctx = query.Context(); if (!ctx.Warning(ctx.Pos(), TIssuesIds::YQL_DEPRECATED_PRAGMA, [](auto& out) { - out << "Use of deprecated DisableUnordered pragma. It will be dropped soon"; - })) { + out << "Use of deprecated DisableUnordered pragma. It will be dropped soon"; + })) { return {}; } return TNodePtr{}; @@ -3386,9 +3354,9 @@ THashMap<TString, TPragmaDescr> PragmaDescrs{ TableElemExt("DisableFlexibleTypes", [](CB_SIG) -> TMaybe<TNodePtr> { auto& ctx = query.Context(); if (!ctx.Warning(ctx.Pos(), TIssuesIds::YQL_DEPRECATED_PRAGMA, [](auto& out) { - out << "Deprecated pragma DisableFlexibleTypes - it will be removed soon. " - << "Consider submitting bug report if FlexibleTypes doesn't work for you"; - })) { + out << "Deprecated pragma DisableFlexibleTypes - it will be removed soon. " + << "Consider submitting bug report if FlexibleTypes doesn't work for you"; + })) { return {}; } ctx.FlexibleTypes = false; @@ -3423,9 +3391,9 @@ THashMap<TString, TPragmaDescr> PragmaDescrs{ TableElemExt("DisableCompactNamedExprs", [](CB_SIG) -> TMaybe<TNodePtr> { auto& ctx = query.Context(); if (!ctx.Warning(ctx.Pos(), TIssuesIds::YQL_DEPRECATED_PRAGMA, [](auto& out) { - out << "Deprecated pragma DisableCompactNamedExprs - it will be removed soon. " - << "Consider submitting bug report if CompactNamedExprs doesn't work for you"; - })) { + out << "Deprecated pragma DisableCompactNamedExprs - it will be removed soon. " + << "Consider submitting bug report if CompactNamedExprs doesn't work for you"; + })) { return {}; } ctx.CompactNamedExprs = false; @@ -3538,8 +3506,7 @@ TMaybe<TNodePtr> TSqlQuery::PragmaStatement(const TRule_pragma_stmt& stmt) { if (stmt.GetBlock4().HasAlt1()) { // pragma=value pragmaValues.push_back(&stmt.GetBlock4().GetAlt1().GetRule_pragma_value2()); - } - else if (stmt.GetBlock4().HasAlt2()) { + } else if (stmt.GetBlock4().HasAlt2()) { // pragma(value,value...) pragmaValues.push_back(&stmt.GetBlock4().GetAlt2().GetRule_pragma_value2()); for (auto& additionalValue : stmt.GetBlock4().GetAlt2().GetBlock3()) { @@ -3576,15 +3543,11 @@ TMaybe<TNodePtr> TSqlQuery::PragmaStatement(const TRule_pragma_stmt& stmt) { } values.push_back(TDeferredAtom(Ctx_.Pos(), prefix + parsed->Content)); - } - else if (pragmaValue->HasAlt_pragma_value2() - && pragmaValue->GetAlt_pragma_value2().GetRule_id1().HasAlt_id2() - && "default" == to_lower(Id(pragmaValue->GetAlt_pragma_value2().GetRule_id1(), *this))) + } else if (pragmaValue->HasAlt_pragma_value2() && pragmaValue->GetAlt_pragma_value2().GetRule_id1().HasAlt_id2() && "default" == to_lower(Id(pragmaValue->GetAlt_pragma_value2().GetRule_id1(), *this))) { // 'DEFAULT' keyword. pragmaValueDefault = true; - } - else if (withConfigure && pragmaValue->HasAlt_pragma_value5()) { + } else if (withConfigure && pragmaValue->HasAlt_pragma_value5()) { // Bind parameter. TString bindName; if (!NamedNodeImpl(pragmaValue->GetAlt_pragma_value5().GetRule_bind_parameter1(), bindName, *this)) { @@ -3614,7 +3577,7 @@ TMaybe<TNodePtr> TSqlQuery::PragmaStatement(const TRule_pragma_stmt& stmt) { if (!allowTopLevelPragmas && !hasLexicalScope) { Error() << "This pragma '" << pragma << "' is not allowed to be used in actions or subqueries"; Ctx_.IncrementMonCounter("sql_errors", "BadPragmaValue"); - return{}; + return {}; } if (auto descr = PragmaDescrs.FindPtr(normalizedPragma)) { @@ -3629,8 +3592,7 @@ TMaybe<TNodePtr> TSqlQuery::PragmaStatement(const TRule_pragma_stmt& stmt) { return result; } else if (normalizedPragma == "dqengine" || normalizedPragma == "blockengine") { Ctx_.IncrementMonCounter("sql_pragma", "DqEngine"); - if (values.size() != 1 || !values[0].GetLiteral() - || ! (*values[0].GetLiteral() == "disable" || *values[0].GetLiteral() == "auto" || *values[0].GetLiteral() == "force")) + if (values.size() != 1 || !values[0].GetLiteral() || !(*values[0].GetLiteral() == "disable" || *values[0].GetLiteral() == "auto" || *values[0].GetLiteral() == "force")) { Error() << "Expected `disable|auto|force' argument for: " << pragma; Ctx_.IncrementMonCounter("sql_errors", "BadPragmaValue"); @@ -3638,7 +3600,7 @@ TMaybe<TNodePtr> TSqlQuery::PragmaStatement(const TRule_pragma_stmt& stmt) { } const bool isDqEngine = normalizedPragma == "dqengine"; auto& enable = isDqEngine ? Ctx_.DqEngineEnable : Ctx_.BlockEngineEnable; - auto& force = isDqEngine ? Ctx_.DqEngineForce : Ctx_.BlockEngineForce; + auto& force = isDqEngine ? Ctx_.DqEngineForce : Ctx_.BlockEngineForce; if (*values[0].GetLiteral() == "disable") { enable = false; force = false; @@ -3654,7 +3616,7 @@ TMaybe<TNodePtr> TSqlQuery::PragmaStatement(const TRule_pragma_stmt& stmt) { if (*Ctx_.Engine == "ytflow") { if (force) { Error() << "Expected `disable|auto` argument for: " << pragma << " pragma " - << "with Engine pragma argument `ytflow`"; + << "with Engine pragma argument `ytflow`"; Ctx_.IncrementMonCounter("sql_errors", "BadPragmaValue"); return {}; @@ -3679,8 +3641,8 @@ TMaybe<TNodePtr> TSqlQuery::PragmaStatement(const TRule_pragma_stmt& stmt) { } if (normalizedPragma == "fast") { if (!Ctx_.Warning(Ctx_.Pos(), TIssuesIds::YQL_DEPRECATED_PRAGMA, [](auto& out) { - out << "Use of deprecated yson.Fast pragma. It will be dropped soon"; - })) { + out << "Use of deprecated yson.Fast pragma. It will be dropped soon"; + })) { return {}; } return TNodePtr{}; @@ -3733,8 +3695,7 @@ TMaybe<TNodePtr> TSqlQuery::PragmaStatement(const TRule_pragma_stmt& stmt) { } else if (std::find(Providers.cbegin(), Providers.cend(), lowerPrefix) == Providers.cend()) { if (!Ctx_.HasCluster(prefix)) { - Error() << "Unknown pragma prefix: " << prefix << ", please use cluster name or one of provider " << - JoinRange(", ", Providers.cbegin(), Providers.cend()); + Error() << "Unknown pragma prefix: " << prefix << ", please use cluster name or one of provider " << JoinRange(", ", Providers.cbegin(), Providers.cend()); Ctx_.IncrementMonCounter("sql_errors", "UnknownPragma"); return {}; } @@ -3779,9 +3740,9 @@ TNodePtr TSqlQuery::Build(const TRule_delete_stmt& stmt) { if (stmt.HasBlock6()) { if (isBatch) { - Ctx_.Error(GetPos(stmt.GetToken2())) - << "BATCH DELETE is unsupported with RETURNING"; - return nullptr; + Ctx_.Error(GetPos(stmt.GetToken2())) + << "BATCH DELETE is unsupported with RETURNING"; + return nullptr; } options = ReturningList(stmt.GetBlock6().GetRule_returning_columns_list1()); @@ -3931,7 +3892,7 @@ TSourcePtr TSqlQuery::Build(const TRule_set_clause_list& stmt) { if (!FillSetClause(stmt.GetRule_set_clause1(), targetList, values)) { return nullptr; } - for (auto& block: stmt.GetBlock2()) { + for (auto& block : stmt.GetBlock2()) { if (!FillSetClause(block.GetRule_set_clause2(), targetList, values)) { return nullptr; } @@ -3978,7 +3939,7 @@ TNodePtr TSqlQuery::Build(const TSQLv1ParserAST& ast) { return nullptr; } - TNodePtr typeNode = BuildBuiltinFunc(Ctx_, Ctx_.Pos(), "ParseType", { BuildLiteralRawString(Ctx_.Pos(), type) }); + TNodePtr typeNode = BuildBuiltinFunc(Ctx_, Ctx_.Pos(), "ParseType", {BuildLiteralRawString(Ctx_.Pos(), type)}); PushNamedAtom(Ctx_.Pos(), varName); // no duplicates are possible at this stage bool isWeak = true; @@ -4000,7 +3961,7 @@ TNodePtr TSqlQuery::Build(const TSQLv1ParserAST& ast) { if (!Statement(blocks, statements.GetRule_sql_stmt2().GetRule_sql_stmt_core2(), statementNumber++)) { return nullptr; } - for (auto block: statements.GetBlock3()) { + for (auto block : statements.GetBlock3()) { if (!Statement(blocks, block.GetRule_sql_stmt2().GetRule_sql_stmt_core2(), statementNumber++)) { return nullptr; } @@ -4023,11 +3984,11 @@ TNodePtr TSqlQuery::Build(const TSQLv1ParserAST& ast) { if ((Mode_ == NSQLTranslation::ESqlMode::SUBQUERY || Mode_ == NSQLTranslation::ESqlMode::LIMITED_VIEW) && (topLevelSelects != 1 || hasTailOps)) { Error() << "Strictly one select/process/reduce statement is expected at the end of " - << (Mode_ == NSQLTranslation::ESqlMode::LIMITED_VIEW ? "view" : "subquery"); + << (Mode_ == NSQLTranslation::ESqlMode::LIMITED_VIEW ? "view" : "subquery"); return nullptr; } - if (!Ctx_.PragmaAutoCommit && Ctx_.Settings.EndOfQueryCommit && IsQueryMode(Mode_)) { + if (!Ctx_.PragmaAutoCommit && Ctx_.Settings.EndOfQueryCommit && IsQueryMode(Mode_)) { AddStatementToBlocks(blocks, BuildCommitClusters(Ctx_.Pos())); } @@ -4058,7 +4019,7 @@ TNodePtr TSqlQuery::Build(const std::vector<::NSQLv1Generated::TRule_sql_stmt_co return nullptr; } - TNodePtr typeNode = BuildBuiltinFunc(Ctx_, Ctx_.Pos(), "ParseType", { BuildLiteralRawString(Ctx_.Pos(), type) }); + TNodePtr typeNode = BuildBuiltinFunc(Ctx_, Ctx_.Pos(), "ParseType", {BuildLiteralRawString(Ctx_.Pos(), type)}); PushNamedAtom(Ctx_.Pos(), varName); // no duplicates are possible at this stage bool isWeak = true; @@ -4097,11 +4058,11 @@ TNodePtr TSqlQuery::Build(const std::vector<::NSQLv1Generated::TRule_sql_stmt_co if ((Mode_ == NSQLTranslation::ESqlMode::SUBQUERY || Mode_ == NSQLTranslation::ESqlMode::LIMITED_VIEW) && (topLevelSelects != 1 || hasTailOps)) { Error() << "Strictly one select/process/reduce statement is expected at the end of " - << (Mode_ == NSQLTranslation::ESqlMode::LIMITED_VIEW ? "view" : "subquery"); + << (Mode_ == NSQLTranslation::ESqlMode::LIMITED_VIEW ? "view" : "subquery"); return nullptr; } - if (!Ctx_.PragmaAutoCommit && Ctx_.Settings.EndOfQueryCommit && IsQueryMode(Mode_)) { + if (!Ctx_.PragmaAutoCommit && Ctx_.Settings.EndOfQueryCommit && IsQueryMode(Mode_)) { AddStatementToBlocks(blocks, BuildCommitClusters(Ctx_.Pos())); } @@ -4110,49 +4071,48 @@ TNodePtr TSqlQuery::Build(const std::vector<::NSQLv1Generated::TRule_sql_stmt_co } namespace { - static bool BuildColumnFeatures(std::map<TString, TDeferredAtom>& result, const TRule_column_schema& columnSchema, const NYql::TPosition& pos, TSqlTranslation& translation) { - const TString columnName(Id(columnSchema.GetRule_an_id_schema1(), translation)); - TString columnType; +static bool BuildColumnFeatures(std::map<TString, TDeferredAtom>& result, const TRule_column_schema& columnSchema, const NYql::TPosition& pos, TSqlTranslation& translation) { + const TString columnName(Id(columnSchema.GetRule_an_id_schema1(), translation)); + TString columnType; - const auto options = ColumnOptions(columnSchema, translation); - if (!options) { - return false; - } + const auto options = ColumnOptions(columnSchema, translation); + if (!options) { + return false; + } - auto& typeBind = columnSchema.GetRule_type_name_or_bind2(); - switch (typeBind.Alt_case()) { - case TRule_type_name_or_bind::kAltTypeNameOrBind1: - { - auto& typeNameOrBind = typeBind.GetAlt_type_name_or_bind1().GetRule_type_name1(); - if (typeNameOrBind.Alt_case() != TRule_type_name::kAltTypeName2) { - return false; - } - auto& alt = typeNameOrBind.GetAlt_type_name2(); - auto& block = alt.GetBlock1(); - auto& simpleType = block.GetAlt2().GetRule_type_name_simple1(); - columnType = Id(simpleType.GetRule_an_id_pure1(), translation); - if (columnType.empty()) { - return false; - } - break; + auto& typeBind = columnSchema.GetRule_type_name_or_bind2(); + switch (typeBind.Alt_case()) { + case TRule_type_name_or_bind::kAltTypeNameOrBind1: { + auto& typeNameOrBind = typeBind.GetAlt_type_name_or_bind1().GetRule_type_name1(); + if (typeNameOrBind.Alt_case() != TRule_type_name::kAltTypeName2) { + return false; } - case TRule_type_name_or_bind::kAltTypeNameOrBind2: + auto& alt = typeNameOrBind.GetAlt_type_name2(); + auto& block = alt.GetBlock1(); + auto& simpleType = block.GetAlt2().GetRule_type_name_simple1(); + columnType = Id(simpleType.GetRule_an_id_pure1(), translation); + if (columnType.empty()) { return false; - case TRule_type_name_or_bind::ALT_NOT_SET: - Y_ABORT("You should change implementation according to grammar changes"); + } + break; } + case TRule_type_name_or_bind::kAltTypeNameOrBind2: + return false; + case TRule_type_name_or_bind::ALT_NOT_SET: + Y_ABORT("You should change implementation according to grammar changes"); + } - result["NAME"] = TDeferredAtom(pos, columnName); - YQL_ENSURE(columnType, "Unknown column type"); - result["TYPE"] = TDeferredAtom(pos, columnType); - if (!options->Nullable) { - result["NOT_NULL"] = TDeferredAtom(pos, "true"); - } - return true; + result["NAME"] = TDeferredAtom(pos, columnName); + YQL_ENSURE(columnType, "Unknown column type"); + result["TYPE"] = TDeferredAtom(pos, columnType); + if (!options->Nullable) { + result["NOT_NULL"] = TDeferredAtom(pos, "true"); } + return true; } +} // namespace -bool TSqlQuery::ParseTableStoreFeatures(std::map<TString, TDeferredAtom> & result, const TRule_alter_table_store_action & actions) { +bool TSqlQuery::ParseTableStoreFeatures(std::map<TString, TDeferredAtom>& result, const TRule_alter_table_store_action& actions) { switch (actions.Alt_case()) { case TRule_alter_table_store_action::kAltAlterTableStoreAction1: { // ADD COLUMN |
