aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials
diff options
context:
space:
mode:
authorzhvv117 <zhvv117@yandex-team.com>2024-12-11 14:04:52 +0300
committerVitaly Isaev <vitalyisaev@ydb.tech>2024-12-12 10:12:06 +0000
commitab4ac36b6b8137f19724a1c8954d30374d1db47d (patch)
tree957c3a1d599d43cbdbfd81e5aa1959d8be1c3605 /yql/essentials
parent62e542ce099d92b5cec3f459ea67af42bdab6d25 (diff)
downloadydb-ab4ac36b6b8137f19724a1c8954d30374d1db47d.tar.gz
fix validation after deleting semicolon in EVALUATE IF and EVALUATE FOR statements
commit_hash:70fbc4792bdf7ec2454ace7656c77697c35aa105
Diffstat (limited to 'yql/essentials')
-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;