aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorInnokentii Mokin <innokentii@ydb.tech>2024-10-21 15:38:40 +0700
committerGitHub <noreply@github.com>2024-10-21 11:38:40 +0300
commit7f4d37b99e25e931918580a353dba7eed11407ee (patch)
tree97c41d08a04b608a7510cd06a2060de2b210fda7
parent3fb6997b618982c100eb94a8e81441cd03688d0a (diff)
downloadydb-7f4d37b99e25e931918580a353dba7eed11407ee.tar.gz
Align create backup collection entries grammar with corresponding topics grammar (#10580)
-rw-r--r--ydb/library/yql/sql/v1/SQLv1.g.in5
-rw-r--r--ydb/library/yql/sql/v1/SQLv1Antlr4.g.in5
-rw-r--r--ydb/library/yql/sql/v1/format/sql_format_ut.h8
-rw-r--r--ydb/library/yql/sql/v1/sql_query.cpp18
-rw-r--r--ydb/library/yql/sql/v1/sql_ut.cpp27
-rw-r--r--ydb/library/yql/sql/v1/sql_ut_antlr4.cpp29
6 files changed, 46 insertions, 46 deletions
diff --git a/ydb/library/yql/sql/v1/SQLv1.g.in b/ydb/library/yql/sql/v1/SQLv1.g.in
index f9fd24ef8a..46f9074095 100644
--- a/ydb/library/yql/sql/v1/SQLv1.g.in
+++ b/ydb/library/yql/sql/v1/SQLv1.g.in
@@ -653,11 +653,12 @@ create_table_entry:
| an_id_schema
;
-create_backup_collection_stmt: CREATE backup_collection WITH LPAREN backup_collection_settings RPAREN database_or_table_list?;
+create_backup_collection_stmt: CREATE backup_collection create_backup_collection_entries? WITH LPAREN backup_collection_settings RPAREN;
alter_backup_collection_stmt: ALTER backup_collection (alter_backup_collection_actions | alter_backup_collection_entries);
drop_backup_collection_stmt: DROP backup_collection;
-database_or_table_list: DATABASE | table_list;
+create_backup_collection_entries: DATABASE | create_backup_collection_entries_many;
+create_backup_collection_entries_many: LPAREN table_list RPAREN;
table_list: TABLE an_id_table (COMMA TABLE an_id_table)*;
alter_backup_collection_actions: alter_backup_collection_action (COMMA alter_backup_collection_action)*;
diff --git a/ydb/library/yql/sql/v1/SQLv1Antlr4.g.in b/ydb/library/yql/sql/v1/SQLv1Antlr4.g.in
index 912ec5e439..3758c6f69c 100644
--- a/ydb/library/yql/sql/v1/SQLv1Antlr4.g.in
+++ b/ydb/library/yql/sql/v1/SQLv1Antlr4.g.in
@@ -652,11 +652,12 @@ create_table_entry:
| an_id_schema
;
-create_backup_collection_stmt: CREATE backup_collection WITH LPAREN backup_collection_settings RPAREN database_or_table_list?;
+create_backup_collection_stmt: CREATE backup_collection create_backup_collection_entries? WITH LPAREN backup_collection_settings RPAREN;
alter_backup_collection_stmt: ALTER backup_collection (alter_backup_collection_actions | alter_backup_collection_entries);
drop_backup_collection_stmt: DROP backup_collection;
-database_or_table_list: DATABASE | table_list;
+create_backup_collection_entries: DATABASE | create_backup_collection_entries_many;
+create_backup_collection_entries_many: LPAREN table_list RPAREN;
table_list: TABLE an_id_table (COMMA TABLE an_id_table)*;
alter_backup_collection_actions: alter_backup_collection_action (COMMA alter_backup_collection_action)*;
diff --git a/ydb/library/yql/sql/v1/format/sql_format_ut.h b/ydb/library/yql/sql/v1/format/sql_format_ut.h
index 609fdd1a95..951bf42798 100644
--- a/ydb/library/yql/sql/v1/format/sql_format_ut.h
+++ b/ydb/library/yql/sql/v1/format/sql_format_ut.h
@@ -1579,10 +1579,10 @@ Y_UNIT_TEST(BackupCollectionOperations) {
TCases cases = {
{"creAte BackuP colLection `-naMe` wIth (a = \"b\")",
"CREATE BACKUP COLLECTION `-naMe` WITH (a = \"b\");\n"},
- {"creAte BackuP colLection `-naMe` wIth (a = \"b\") DATabase",
- "CREATE BACKUP COLLECTION `-naMe` WITH (a = \"b\") DATABASE;\n"},
- {"creAte BackuP colLection `-naMe` wIth (a = \"b\") tabLe `tbl1` , TablE `tbl2`",
- "CREATE BACKUP COLLECTION `-naMe` WITH (a = \"b\") TABLE `tbl1`, TABLE `tbl2`;\n"},
+ {"creAte BackuP colLection `-naMe` DATabase wIth (a = \"b\")",
+ "CREATE BACKUP COLLECTION `-naMe` DATABASE WITH (a = \"b\");\n"},
+ {"creAte BackuP colLection `-naMe` ( tabLe `tbl1` , TablE `tbl2`) wIth (a = \"b\")",
+ "CREATE BACKUP COLLECTION `-naMe` (TABLE `tbl1`, TABLE `tbl2`) WITH (a = \"b\");\n"},
{"alTer bACKuP coLLECTION naMe resEt (b, c), seT (x=y, z=false)",
"ALTER BACKUP COLLECTION naMe\n\tRESET (b, c),\n\tSET (x = y, z = FALSE);\n"},
{"alTer bACKuP coLLECTION naMe aDD DATAbase",
diff --git a/ydb/library/yql/sql/v1/sql_query.cpp b/ydb/library/yql/sql/v1/sql_query.cpp
index 664458a7ba..36a3488673 100644
--- a/ydb/library/yql/sql/v1/sql_query.cpp
+++ b/ydb/library/yql/sql/v1/sql_query.cpp
@@ -1388,16 +1388,24 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core&
}
std::map<TString, TDeferredAtom> kv;
- if (!ParseBackupCollectionSettings(kv, node.GetRule_backup_collection_settings5())) {
+ if (!ParseBackupCollectionSettings(kv, node.GetRule_backup_collection_settings6())) {
return false;
}
bool database = false;
TVector<TDeferredAtom> tables;
- if (node.HasBlock7()) {
- database = node.GetBlock7().GetRule_database_or_table_list1().has_alt_database_or_table_list1();
- if (node.GetBlock7().GetRule_database_or_table_list1().has_alt_database_or_table_list2()) {
- if (!ParseBackupCollectionTables(tables, node.GetBlock7().GetRule_database_or_table_list1().alt_database_or_table_list2().rule_table_list1())) {
+ 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;
}
}
diff --git a/ydb/library/yql/sql/v1/sql_ut.cpp b/ydb/library/yql/sql/v1/sql_ut.cpp
index ce51a73969..b6b209a9bb 100644
--- a/ydb/library/yql/sql/v1/sql_ut.cpp
+++ b/ydb/library/yql/sql/v1/sql_ut.cpp
@@ -7051,11 +7051,10 @@ Y_UNIT_TEST_SUITE(BackupCollection) {
Y_UNIT_TEST(CreateBackupCollectionWithDatabase) {
NYql::TAstParseResult res = SqlToYql(R"sql(
USE plato;
- CREATE BACKUP COLLECTION TestCollection WITH (
+ CREATE BACKUP COLLECTION TestCollection DATABASE WITH (
STORAGE="local",
TAG="test" -- for testing purposes, not a real thing
- )
- DATABASE;
+ );
)sql");
UNIT_ASSERT_C(res.Root, res.Issues.ToString());
@@ -7077,12 +7076,13 @@ Y_UNIT_TEST_SUITE(BackupCollection) {
Y_UNIT_TEST(CreateBackupCollectionWithTables) {
NYql::TAstParseResult res = SqlToYql(R"sql(
USE plato;
- CREATE BACKUP COLLECTION TestCollection WITH (
+ CREATE BACKUP COLLECTION TestCollection (
+ TABLE someTable,
+ TABLE `prefix/anotherTable`
+ ) WITH (
STORAGE="local",
TAG="test" -- for testing purposes, not a real thing
- )
- TABLE someTable,
- TABLE `prefix/anotherTable`;
+ );
)sql");
UNIT_ASSERT_C(res.Root, res.Issues.ToString());
@@ -7110,18 +7110,13 @@ Y_UNIT_TEST_SUITE(BackupCollection) {
ExpectFailWithError(R"sql(
USE plato;
- CREATE BACKUP COLLECTION TestCollection TABLE;
- )sql" , "<main>:3:56: Error: Unexpected token 'TABLE' : syntax error...\n\n");
-
- ExpectFailWithError(R"sql(
- USE plato;
- CREATE BACKUP COLLECTION TestCollection DATABASE `test`;
- )sql" , "<main>:3:56: Error: Unexpected token 'DATABASE' : syntax error...\n\n");
+ CREATE BACKUP COLLECTION TABLE TestCollection;
+ )sql" , "<main>:3:47: Error: Unexpected token 'TestCollection' : syntax error...\n\n");
ExpectFailWithError(R"sql(
USE plato;
- CREATE BACKUP COLLECTION TestCollection DATABASE, TABLE `test`;
- )sql" , "<main>:3:56: Error: Unexpected token 'DATABASE' : syntax error...\n\n");
+ CREATE BACKUP COLLECTION DATABASE `test` TestCollection;
+ )sql" , "<main>:3:50: Error: Unexpected token '`test`' : syntax error...\n\n");
ExpectFailWithError(R"sql(
USE plato;
diff --git a/ydb/library/yql/sql/v1/sql_ut_antlr4.cpp b/ydb/library/yql/sql/v1/sql_ut_antlr4.cpp
index c753b2ea3f..95620865d4 100644
--- a/ydb/library/yql/sql/v1/sql_ut_antlr4.cpp
+++ b/ydb/library/yql/sql/v1/sql_ut_antlr4.cpp
@@ -7048,11 +7048,10 @@ Y_UNIT_TEST_SUITE(BackupCollection) {
Y_UNIT_TEST(CreateBackupCollectionWithDatabase) {
NYql::TAstParseResult res = SqlToYql(R"sql(
USE plato;
- CREATE BACKUP COLLECTION TestCollection WITH (
+ CREATE BACKUP COLLECTION TestCollection DATABASE WITH (
STORAGE="local",
TAG="test" -- for testing purposes, not a real thing
- )
- DATABASE;
+ );
)sql");
UNIT_ASSERT_C(res.Root, res.Issues.ToString());
@@ -7074,12 +7073,13 @@ Y_UNIT_TEST_SUITE(BackupCollection) {
Y_UNIT_TEST(CreateBackupCollectionWithTables) {
NYql::TAstParseResult res = SqlToYql(R"sql(
USE plato;
- CREATE BACKUP COLLECTION TestCollection WITH (
+ CREATE BACKUP COLLECTION TestCollection (
+ TABLE someTable,
+ TABLE `prefix/anotherTable`
+ ) WITH (
STORAGE="local",
TAG="test" -- for testing purposes, not a real thing
- )
- TABLE someTable,
- TABLE `prefix/anotherTable`;
+ );
)sql");
UNIT_ASSERT_C(res.Root, res.Issues.ToString());
@@ -7103,22 +7103,17 @@ Y_UNIT_TEST_SUITE(BackupCollection) {
ExpectFailWithError(R"sql(
USE plato;
CREATE BACKUP COLLECTION TestCollection;
- )sql" , "<main>:3:55: Error: mismatched input ';' expecting WITH\n");
-
- ExpectFailWithError(R"sql(
- USE plato;
- CREATE BACKUP COLLECTION TestCollection TABLE;
- )sql" , "<main>:3:56: Error: mismatched input 'TABLE' expecting WITH\n");
+ )sql" , "<main>:3:55: Error: mismatched input ';' expecting {'(', DATABASE, WITH}\n");
ExpectFailWithError(R"sql(
USE plato;
- CREATE BACKUP COLLECTION TestCollection DATABASE `test`;
- )sql" , "<main>:3:56: Error: mismatched input 'DATABASE' expecting WITH\n");
+ CREATE BACKUP COLLECTION TABLE TestCollection;
+ )sql" , "<main>:3:47: Error: mismatched input 'TestCollection' expecting {'(', DATABASE, WITH}\n");
ExpectFailWithError(R"sql(
USE plato;
- CREATE BACKUP COLLECTION TestCollection DATABASE, TABLE `test`;
- )sql" , "<main>:3:56: Error: mismatched input 'DATABASE' expecting WITH\n");
+ CREATE BACKUP COLLECTION DATABASE `test` TestCollection;
+ )sql" , "<main>:3:50: Error: mismatched input '`test`' expecting {'(', DATABASE, WITH}\n");
ExpectFailWithError(R"sql(
USE plato;