aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhvv117 <zhvv117@yandex-team.com>2024-12-11 14:04:52 +0300
committerzhvv117 <zhvv117@yandex-team.com>2024-12-11 14:33:53 +0300
commit9a7f3deaf097e9f100b63719b93a07f5dbbc157c (patch)
tree5122f2a91e92e3640a841f1007fbd631d9554dc5
parent522b83bfb48c40d1819511659dcd34f91eb64b91 (diff)
downloadydb-9a7f3deaf097e9f100b63719b93a07f5dbbc157c.tar.gz
fix validation after deleting semicolon in EVALUATE IF and EVALUATE FOR statements
commit_hash:70fbc4792bdf7ec2454ace7656c77697c35aa105
-rw-r--r--yql/essentials/sql/v1/format/sql_format.cpp2
-rw-r--r--yql/essentials/sql/v1/format/sql_format_ut.h5
2 files changed, 6 insertions, 1 deletions
diff --git a/yql/essentials/sql/v1/format/sql_format.cpp b/yql/essentials/sql/v1/format/sql_format.cpp
index f8e20849fd..8c4b04760f 100644
--- a/yql/essentials/sql/v1/format/sql_format.cpp
+++ b/yql/essentials/sql/v1/format/sql_format.cpp
@@ -62,7 +62,7 @@ void SkipForValidate(
while (
in != query.end() && in->Name == "SEMICOLON" &&
(out == formattedQuery.end() || out->Name != "SEMICOLON") &&
- in != query.begin() && IsIn({"SEMICOLON", "LBRACE_CURLY", "AS"}, SkipWSOrCommentBackward(in - 1, query.begin())->Name)
+ in != query.begin() && IsIn({"SEMICOLON", "LBRACE_CURLY", "AS", "BEGIN"}, SkipWSOrCommentBackward(in - 1, query.begin())->Name)
) {
in = SkipWS(++in, query.end());
}
diff --git a/yql/essentials/sql/v1/format/sql_format_ut.h b/yql/essentials/sql/v1/format/sql_format_ut.h
index 7fe74f2d62..57bcef4bff 100644
--- a/yql/essentials/sql/v1/format/sql_format_ut.h
+++ b/yql/essentials/sql/v1/format/sql_format_ut.h
@@ -593,6 +593,9 @@ Y_UNIT_TEST(If) {
{"evaluate if 1=1 do begin select 1; end do else do begin select 2; end do",
"EVALUATE IF 1 == 1 DO BEGIN\n\tSELECT\n\t\t1\n\t;\nEND DO "
"ELSE DO BEGIN\n\tSELECT\n\t\t2\n\t;\nEND DO;\n"},
+ {"evaluate if 1=1 do begin; select 1 end do else do begin select 2;; select 3 end do",
+ "EVALUATE IF 1 == 1 DO BEGIN\n\tSELECT\n\t\t1\n\t;\nEND DO ELSE DO BEGIN\n\t"
+ "SELECT\n\t\t2\n\t;\n\n\tSELECT\n\t\t3\n\t;\nEND DO;\n"}
};
TSetup setup;
@@ -611,6 +614,8 @@ Y_UNIT_TEST(For) {
"EVALUATE FOR $x IN [] DO BEGIN\n\tSELECT\n\t\t$x\n\t;\nEND DO ELSE DO BEGIN\n\tSELECT\n\t\t2\n\t;\nEND DO;\n"},
{"evaluate parallel for $x in [] do $a($x)",
"EVALUATE PARALLEL FOR $x IN [] DO\n\t$a($x)\n;\n"},
+ {"evaluate for $x in [] do begin; select $x;; select $y end do",
+ "EVALUATE FOR $x IN [] DO BEGIN\n\tSELECT\n\t\t$x\n\t;\n\n\tSELECT\n\t\t$y\n\t;\nEND DO;\n"},
};
TSetup setup;