Skip to content

Commit 5c6755b

Browse files
author
flown4qqqq
committed
Fix bugs with parsing alter database (+add ut on compiling)
commit_hash:7e6d742dce448b1c5f815abebd781049e7b22b46
1 parent 8b363a0 commit 5c6755b

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

yql/essentials/sql/v1/node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ namespace NSQLTranslationV1 {
12781278
};
12791279

12801280
struct TAlterDatabaseParameters {
1281-
TString DbPath;
1281+
TDeferredAtom DbPath;
12821282
std::optional<TDeferredAtom> Owner;
12831283
};
12841284

yql/essentials/sql/v1/query.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,15 +1337,13 @@ class TAlterDatabaseNode final : public TAstListNode {
13371337

13381338
auto options = Y(Q(Y(Q("mode"), Q("alterDatabase"))));
13391339

1340-
options = L(options, Q(Y(Q("dbPath"), Q(Params.DbPath))));
1341-
13421340
if (Params.Owner.has_value()) {
1343-
options = L(options, Q(Y(Q("owner"), Q(Params.Owner.value().Build()))));
1341+
options = L(options, Q(Y(Q("owner"), Params.Owner.value().Build())));
13441342
}
13451343

13461344
Add("block", Q(Y(
13471345
Y("let", "sink", Y("DataSink", BuildQuotedAtom(Pos, Service), cluster)),
1348-
Y("let", "world", Y(TString(WriteName), "world", "sink", Q(options))),
1346+
Y("let", "world", Y(TString(WriteName), "world", "sink", Y("Key", Q(Y(Q("databasePath"), Y("String", Params.DbPath.Build())))), Y("Void"), Q(options))),
13491347
Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world"))
13501348
)));
13511349

yql/essentials/sql/v1/sql_query.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core&
19391939

19401940
TAlterDatabaseParameters alterDatabaseParams;
19411941
alterDatabaseParams.Owner = roleName;
1942-
alterDatabaseParams.DbPath = Id(node.GetRule_an_id_schema3(), *this);
1942+
alterDatabaseParams.DbPath = TDeferredAtom(Ctx.Pos(), Id(node.GetRule_an_id_schema3(), *this));
19431943

19441944
const TPosition pos = Ctx.Pos();
19451945
TString service = Ctx.Scoped->CurrService;

yql/essentials/sql/v1/sql_ut.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) {
977977
Y_UNUSED(word);
978978

979979
UNIT_ASSERT_VALUES_UNEQUAL(TString::npos, line.find(
980-
R"(let world (Write! world sink '('('mode 'alterDatabase) '('dbPath '/Root/test) '('owner ''"user1"))))"
980+
R"(let world (Write! world sink (Key '('databasePath (String '"/Root/test"))) (Void) '('('mode 'alterDatabase) '('owner '"user1"))))"
981981
));
982982
};
983983

yql/essentials/sql/v1/sql_ut_antlr4.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) {
10951095
Y_UNUSED(word);
10961096

10971097
UNIT_ASSERT_VALUES_UNEQUAL(TString::npos, line.find(
1098-
R"(let world (Write! world sink '('('mode 'alterDatabase) '('dbPath '/Root/test) '('owner ''"user1"))))"
1098+
R"(let world (Write! world sink (Key '('databasePath (String '"/Root/test"))) (Void) '('('mode 'alterDatabase) '('owner '"user1"))))"
10991099
));
11001100
};
11011101

0 commit comments

Comments
 (0)