summaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/complete/sql_complete_ut.cpp
diff options
context:
space:
mode:
authorvityaman <[email protected]>2025-03-28 22:01:21 +0300
committerrobot-piglet <[email protected]>2025-03-28 22:36:16 +0300
commitb60cb8f5ce78ae5f63304a534278e124d31398b0 (patch)
tree033d726f561f37e4e258460159b3b379aa9c70f6 /yql/essentials/sql/v1/complete/sql_complete_ut.cpp
parentdf00f0d151a43de80f6e41291d9267afbbfb18a4 (diff)
YQL-19747 Complete Function Names
- Function names are suggested now - Changed the module structure - Checking ruleIndex independence on mode (ansi | default) via unit tests --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1163 commit_hash:1b1a27d2cff8db663c5c7e8efb57896476823315
Diffstat (limited to 'yql/essentials/sql/v1/complete/sql_complete_ut.cpp')
-rw-r--r--yql/essentials/sql/v1/complete/sql_complete_ut.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/yql/essentials/sql/v1/complete/sql_complete_ut.cpp b/yql/essentials/sql/v1/complete/sql_complete_ut.cpp
index aa242d313cb..5f07d5c3388 100644
--- a/yql/essentials/sql/v1/complete/sql_complete_ut.cpp
+++ b/yql/essentials/sql/v1/complete/sql_complete_ut.cpp
@@ -35,6 +35,7 @@ public:
};
Y_UNIT_TEST_SUITE(SqlCompleteTests) {
+ using ECandidateKind::FunctionName;
using ECandidateKind::Keyword;
using ECandidateKind::TypeName;
@@ -53,6 +54,7 @@ Y_UNIT_TEST_SUITE(SqlCompleteTests) {
TLexerSupplier lexer = MakePureLexerSupplier();
INameService::TPtr names = MakeStaticNameService({
.Types = {"Uint64"},
+ .Functions = {"StartsWith"},
});
return MakeSqlCompletionEngine(std::move(lexer), std::move(names));
}
@@ -263,27 +265,53 @@ Y_UNIT_TEST_SUITE(SqlCompleteTests) {
Y_UNIT_TEST(Pragma) {
TVector<TCandidate> expected = {
{Keyword, "ANSI"},
+ };
+
+ auto engine = MakeSqlCompletionEngineUT();
+ UNIT_ASSERT_VALUES_EQUAL(Complete(engine, {"PRAGMA "}), expected);
+ }
+
+ Y_UNIT_TEST(Select) {
+ TVector<TCandidate> expected = {
+ {Keyword, "ALL"},
+ {Keyword, "BITCAST"},
{Keyword, "CALLABLE"},
+ {Keyword, "CASE"},
+ {Keyword, "CAST"},
+ {Keyword, "CURRENT_DATE"},
+ {Keyword, "CURRENT_TIME"},
+ {Keyword, "CURRENT_TIMESTAMP"},
{Keyword, "DICT"},
+ {Keyword, "DISTINCT"},
+ {Keyword, "EMPTY_ACTION"},
{Keyword, "ENUM"},
+ {Keyword, "EXISTS"},
+ {Keyword, "FALSE"},
{Keyword, "FLOW"},
+ {Keyword, "JSON_EXISTS"},
+ {Keyword, "JSON_QUERY"},
+ {Keyword, "JSON_VALUE"},
{Keyword, "LIST"},
+ {Keyword, "NOT"},
+ {Keyword, "NULL"},
{Keyword, "OPTIONAL"},
{Keyword, "RESOURCE"},
{Keyword, "SET"},
+ {Keyword, "STREAM"},
{Keyword, "STRUCT"},
{Keyword, "TAGGED"},
+ {Keyword, "TRUE"},
{Keyword, "TUPLE"},
{Keyword, "VARIANT"},
+ {FunctionName, "StartsWith"},
};
auto engine = MakeSqlCompletionEngineUT();
- UNIT_ASSERT_VALUES_EQUAL(Complete(engine, {"PRAGMA "}), expected);
+ UNIT_ASSERT_VALUES_EQUAL(Complete(engine, {"SELECT "}), expected);
}
- Y_UNIT_TEST(Select) {
+ Y_UNIT_TEST(SelectWhere) {
TVector<TCandidate> expected = {
- {Keyword, "ALL"},
{Keyword, "BITCAST"},
{Keyword, "CALLABLE"},
{Keyword, "CASE"},
@@ -292,7 +320,6 @@ Y_UNIT_TEST_SUITE(SqlCompleteTests) {
{Keyword, "CURRENT_TIME"},
{Keyword, "CURRENT_TIMESTAMP"},
{Keyword, "DICT"},
- {Keyword, "DISTINCT"},
{Keyword, "EMPTY_ACTION"},
{Keyword, "ENUM"},
{Keyword, "EXISTS"},
@@ -313,10 +340,11 @@ Y_UNIT_TEST_SUITE(SqlCompleteTests) {
{Keyword, "TRUE"},
{Keyword, "TUPLE"},
{Keyword, "VARIANT"},
+ {FunctionName, "StartsWith"},
};
auto engine = MakeSqlCompletionEngineUT();
- UNIT_ASSERT_VALUES_EQUAL(Complete(engine, {"SELECT "}), expected);
+ UNIT_ASSERT_VALUES_EQUAL(Complete(engine, {"SELECT * FROM a WHERE "}), expected);
}
Y_UNIT_TEST(Upsert) {
@@ -362,7 +390,7 @@ Y_UNIT_TEST_SUITE(SqlCompleteTests) {
Y_UNIT_TEST(WordBreak) {
auto engine = MakeSqlCompletionEngineUT();
- UNIT_ASSERT_VALUES_EQUAL(Complete(engine, {"SELECT ("}).size(), 28);
+ UNIT_ASSERT_VALUES_EQUAL(Complete(engine, {"SELECT ("}).size(), 29);
UNIT_ASSERT_VALUES_EQUAL(Complete(engine, {"SELECT (1)"}).size(), 30);
UNIT_ASSERT_VALUES_EQUAL(Complete(engine, {"SELECT 1;"}).size(), 35);
}
@@ -448,6 +476,7 @@ Y_UNIT_TEST_SUITE(SqlCompleteTests) {
auto engine = MakeSqlCompletionEngine(MakePureLexerSupplier(), std::move(fallback));
UNIT_ASSERT_VALUES_EQUAL(Complete(engine, {"SELECT CAST (1 AS U"}).size(), 6);
UNIT_ASSERT_VALUES_EQUAL(Complete(engine, {"SELECT CAST (1 AS "}).size(), 47);
+ UNIT_ASSERT_VALUES_EQUAL(Complete(engine, {"SELECT "}).size(), 55);
}
} // Y_UNIT_TEST_SUITE(SqlCompleteTests)