@@ -2533,8 +2533,8 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) {
2533
2533
const auto result = SqlToYql (R"( USE plato;
2534
2534
CREATE TABLE table (
2535
2535
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
2538
2538
ON (col) COVER (col)
2539
2539
WITH (distance=cosine, vector_type=float, vector_dimension=1024,),
2540
2540
PRIMARY KEY (pk))
@@ -2543,11 +2543,11 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) {
2543
2543
}
2544
2544
2545
2545
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
2549
2549
ON (col) COVER (col)
2550
- WITH (distance=cosine, vector_type="float", vector_dimension=1024)
2550
+ WITH (distance=cosine, vector_type="float", vector_dimension=1024)
2551
2551
)" );
2552
2552
UNIT_ASSERT_C (result.IsOk (), result.Issues .ToString ());
2553
2553
}
@@ -2558,11 +2558,11 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) {
2558
2558
}
2559
2559
2560
2560
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
2564
2564
ON (col)
2565
- WITH (distance=cosine, vector_type=float)
2565
+ WITH (distance=cosine, vector_type=float)
2566
2566
)" ,
2567
2567
" <main>:5:52: Error: vector_dimension should be set\n " );
2568
2568
}
@@ -2790,7 +2790,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) {
2790
2790
auto req = Sprintf (reqTpl, key.c_str (), value.c_str ());
2791
2791
auto res = SqlToYql (req);
2792
2792
UNIT_ASSERT (res.Root );
2793
-
2793
+
2794
2794
TVerifyLineFunc verifyLine = [&key, &value](const TString& word, const TString& line) {
2795
2795
if (word == " Write" ) {
2796
2796
UNIT_ASSERT_VALUES_UNEQUAL (TString::npos, line.find (" MyReplication" ));
@@ -6716,6 +6716,28 @@ Y_UNIT_TEST_SUITE(TViewSyntaxTest) {
6716
6716
UNIT_ASSERT_C (res.Root , res.Issues .ToString ());
6717
6717
}
6718
6718
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
+
6719
6741
Y_UNIT_TEST (CreateViewFromTable) {
6720
6742
constexpr const char * path = " /PathPrefix/TheView" ;
6721
6743
constexpr const char * query = R"(
@@ -6795,6 +6817,28 @@ Y_UNIT_TEST_SUITE(TViewSyntaxTest) {
6795
6817
UNIT_ASSERT_VALUES_EQUAL (elementStat[" Write!" ], 1 );
6796
6818
}
6797
6819
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
+
6798
6842
Y_UNIT_TEST (CreateViewWithTablePrefix) {
6799
6843
NYql::TAstParseResult res = SqlToYql (R"(
6800
6844
USE plato;
@@ -6838,7 +6882,7 @@ Y_UNIT_TEST_SUITE(TViewSyntaxTest) {
6838
6882
6839
6883
UNIT_ASSERT_VALUES_EQUAL (elementStat[" Write!" ], 1 );
6840
6884
}
6841
-
6885
+
6842
6886
Y_UNIT_TEST (YtAlternativeSchemaSyntax) {
6843
6887
NYql::TAstParseResult res = SqlToYql (R"(
6844
6888
SELECT * FROM plato.Input WITH schema(y Int32, x String not null);
@@ -6907,7 +6951,7 @@ Y_UNIT_TEST_SUITE(CompactNamedExprs) {
6907
6951
pragma CompactNamedExprs;
6908
6952
pragma ValidateUnusedExprs;
6909
6953
6910
- define subquery $x() as
6954
+ define subquery $x() as
6911
6955
select count(1, 2);
6912
6956
end define;
6913
6957
select 1;
@@ -6930,7 +6974,7 @@ Y_UNIT_TEST_SUITE(CompactNamedExprs) {
6930
6974
pragma CompactNamedExprs;
6931
6975
pragma DisableValidateUnusedExprs;
6932
6976
6933
- define subquery $x() as
6977
+ define subquery $x() as
6934
6978
select count(1, 2);
6935
6979
end define;
6936
6980
select 1;
0 commit comments