@@ -2533,8 +2533,8 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) {
25332533 const auto result = SqlToYql (R"( USE plato;
25342534 CREATE TABLE table (
25352535 pk INT32 NOT NULL,
2536- col String,
2537- INDEX idx GLOBAL USING vector_kmeans_tree
2536+ col String,
2537+ INDEX idx GLOBAL USING vector_kmeans_tree
25382538 ON (col) COVER (col)
25392539 WITH (distance=cosine, vector_type=float, vector_dimension=1024,),
25402540 PRIMARY KEY (pk))
@@ -2543,11 +2543,11 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) {
25432543 }
25442544
25452545 Y_UNIT_TEST (AlterTableAddIndexVector) {
2546- const auto result = SqlToYql (R"( USE plato;
2547- ALTER TABLE table ADD INDEX idx
2548- GLOBAL USING vector_kmeans_tree
2546+ const auto result = SqlToYql (R"( USE plato;
2547+ ALTER TABLE table ADD INDEX idx
2548+ GLOBAL USING vector_kmeans_tree
25492549 ON (col) COVER (col)
2550- WITH (distance=cosine, vector_type="float", vector_dimension=1024)
2550+ WITH (distance=cosine, vector_type="float", vector_dimension=1024)
25512551 )" );
25522552 UNIT_ASSERT_C (result.IsOk (), result.Issues .ToString ());
25532553 }
@@ -2558,11 +2558,11 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) {
25582558 }
25592559
25602560 Y_UNIT_TEST (AlterTableAddIndexMissedParameter) {
2561- ExpectFailWithError (R"( USE plato;
2562- ALTER TABLE table ADD INDEX idx
2563- GLOBAL USING vector_kmeans_tree
2561+ ExpectFailWithError (R"( USE plato;
2562+ ALTER TABLE table ADD INDEX idx
2563+ GLOBAL USING vector_kmeans_tree
25642564 ON (col)
2565- WITH (distance=cosine, vector_type=float)
2565+ WITH (distance=cosine, vector_type=float)
25662566 )" ,
25672567 " <main>:5:52: Error: vector_dimension should be set\n " );
25682568 }
@@ -2790,7 +2790,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) {
27902790 auto req = Sprintf (reqTpl, key.c_str (), value.c_str ());
27912791 auto res = SqlToYql (req);
27922792 UNIT_ASSERT (res.Root );
2793-
2793+
27942794 TVerifyLineFunc verifyLine = [&key, &value](const TString& word, const TString& line) {
27952795 if (word == " Write" ) {
27962796 UNIT_ASSERT_VALUES_UNEQUAL (TString::npos, line.find (" MyReplication" ));
@@ -6716,6 +6716,28 @@ Y_UNIT_TEST_SUITE(TViewSyntaxTest) {
67166716 UNIT_ASSERT_C (res.Root , res.Issues .ToString ());
67176717 }
67186718
6719+ Y_UNIT_TEST (CreateViewIfNotExists) {
6720+ constexpr const char * name = " TheView" ;
6721+ NYql::TAstParseResult res = SqlToYql (std::format (R"(
6722+ USE plato;
6723+ CREATE VIEW IF NOT EXISTS {} WITH (security_invoker = TRUE) AS SELECT 1;
6724+ )" , name
6725+ ));
6726+ UNIT_ASSERT_C (res.Root , res.Issues .ToString ());
6727+
6728+ TVerifyLineFunc verifyLine = [&](const TString& word, const TString& line) {
6729+ if (word == " Write!" ) {
6730+ UNIT_ASSERT_STRING_CONTAINS (line, name);
6731+ UNIT_ASSERT_STRING_CONTAINS (line, " createObjectIfNotExists" );
6732+ }
6733+ };
6734+
6735+ TWordCountHive elementStat = { {" Write!" } };
6736+ VerifyProgram (res, elementStat, verifyLine);
6737+
6738+ UNIT_ASSERT_VALUES_EQUAL (elementStat[" Write!" ], 1 );
6739+ }
6740+
67196741 Y_UNIT_TEST (CreateViewFromTable) {
67206742 constexpr const char * path = " /PathPrefix/TheView" ;
67216743 constexpr const char * query = R"(
@@ -6795,6 +6817,28 @@ Y_UNIT_TEST_SUITE(TViewSyntaxTest) {
67956817 UNIT_ASSERT_VALUES_EQUAL (elementStat[" Write!" ], 1 );
67966818 }
67976819
6820+ Y_UNIT_TEST (DropViewIfExists) {
6821+ constexpr const char * name = " TheView" ;
6822+ NYql::TAstParseResult res = SqlToYql (std::format (R"(
6823+ USE plato;
6824+ DROP VIEW IF EXISTS {};
6825+ )" , name
6826+ ));
6827+ UNIT_ASSERT_C (res.Root , res.Issues .ToString ());
6828+
6829+ TVerifyLineFunc verifyLine = [&](const TString& word, const TString& line) {
6830+ if (word == " Write!" ) {
6831+ UNIT_ASSERT_STRING_CONTAINS (line, name);
6832+ UNIT_ASSERT_STRING_CONTAINS (line, " dropObjectIfExists" );
6833+ }
6834+ };
6835+
6836+ TWordCountHive elementStat = { {" Write!" } };
6837+ VerifyProgram (res, elementStat, verifyLine);
6838+
6839+ UNIT_ASSERT_VALUES_EQUAL (elementStat[" Write!" ], 1 );
6840+ }
6841+
67986842 Y_UNIT_TEST (CreateViewWithTablePrefix) {
67996843 NYql::TAstParseResult res = SqlToYql (R"(
68006844 USE plato;
@@ -6838,7 +6882,7 @@ Y_UNIT_TEST_SUITE(TViewSyntaxTest) {
68386882
68396883 UNIT_ASSERT_VALUES_EQUAL (elementStat[" Write!" ], 1 );
68406884 }
6841-
6885+
68426886 Y_UNIT_TEST (YtAlternativeSchemaSyntax) {
68436887 NYql::TAstParseResult res = SqlToYql (R"(
68446888 SELECT * FROM plato.Input WITH schema(y Int32, x String not null);
@@ -6907,7 +6951,7 @@ Y_UNIT_TEST_SUITE(CompactNamedExprs) {
69076951 pragma CompactNamedExprs;
69086952 pragma ValidateUnusedExprs;
69096953
6910- define subquery $x() as
6954+ define subquery $x() as
69116955 select count(1, 2);
69126956 end define;
69136957 select 1;
@@ -6930,7 +6974,7 @@ Y_UNIT_TEST_SUITE(CompactNamedExprs) {
69306974 pragma CompactNamedExprs;
69316975 pragma DisableValidateUnusedExprs;
69326976
6933- define subquery $x() as
6977+ define subquery $x() as
69346978 select count(1, 2);
69356979 end define;
69366980 select 1;
0 commit comments