summaryrefslogtreecommitdiffstats
path: root/yql/essentials/parser/lexer_common/ut/hints_ut.cpp
diff options
context:
space:
mode:
authorvvvv <[email protected]>2025-02-19 17:28:26 +0300
committervvvv <[email protected]>2025-02-19 17:46:38 +0300
commit52daccf61e2e827114cfb3372071cddaec7974ba (patch)
tree07404f6ec241c8a2b96a4da07dc0f0d0c247799c /yql/essentials/parser/lexer_common/ut/hints_ut.cpp
parentca4b5f28703b0d06599c94f3eacc5d6c498c31d5 (diff)
YQL-19594 Explicit lexers & parsers
commit_hash:6be543b7c5bff6ee474ee606c920197fb2569767
Diffstat (limited to 'yql/essentials/parser/lexer_common/ut/hints_ut.cpp')
-rw-r--r--yql/essentials/parser/lexer_common/ut/hints_ut.cpp22
1 files changed, 6 insertions, 16 deletions
diff --git a/yql/essentials/parser/lexer_common/ut/hints_ut.cpp b/yql/essentials/parser/lexer_common/ut/hints_ut.cpp
index 0ddce933644..2542c1ac266 100644
--- a/yql/essentials/parser/lexer_common/ut/hints_ut.cpp
+++ b/yql/essentials/parser/lexer_common/ut/hints_ut.cpp
@@ -1,5 +1,6 @@
#include <yql/essentials/parser/lexer_common/hints.h>
#include <yql/essentials/sql/v1/lexer/lexer.h>
+#include <yql/essentials/sql/v1/lexer/antlr4/lexer.h>
#include <library/cpp/testing/unittest/registar.h>
@@ -8,9 +9,11 @@
using namespace NSQLTranslation;
using namespace NSQLTranslationV1;
-TSQLHints CollectHints(const TString& query, bool antlr4Parser) {
+TSQLHints CollectHints(const TString& query) {
+ NSQLTranslationV1::TLexers lexers;
+ lexers.Antlr4 = NSQLTranslationV1::MakeAntlr4LexerFactory();
bool ansi = false;
- auto lexer = MakeLexer(ansi, antlr4Parser);
+ auto lexer = MakeLexer(lexers, ansi, true);
UNIT_ASSERT(lexer);
TSQLHints result;
NYql::TIssues issues;
@@ -27,20 +30,7 @@ TString SerializeHints(const TVector<TSQLHint>& hints) {
Y_UNIT_TEST_SUITE(TLexerHintsTests) {
Y_UNIT_TEST(Basic) {
TString query = "/*+ some() */ SELECT /*+ foo(one) */ --+ bar(two)";
- auto hintsWithPos = CollectHints(query, false);
- UNIT_ASSERT(hintsWithPos.size() == 1);
- NYql::TPosition pos = hintsWithPos.begin()->first;
- TVector<TSQLHint> hints = hintsWithPos.begin()->second;
-
- UNIT_ASSERT_EQUAL(pos.Row, 1);
- UNIT_ASSERT_EQUAL(pos.Column, 15);
-
- TStringBuf expected = R"raw("foo":{"one"},"bar":{"two"})raw";
- UNIT_ASSERT_NO_DIFF(SerializeHints(hints), expected);
- }
- Y_UNIT_TEST(Antlr4) {
- TString query = "/*+ some() */ SELECT /*+ foo(one) */ --+ bar(two)";
- auto hintsWithPos = CollectHints(query, true);
+ auto hintsWithPos = CollectHints(query);
UNIT_ASSERT(hintsWithPos.size() == 1);
NYql::TPosition pos = hintsWithPos.begin()->first;
TVector<TSQLHint> hints = hintsWithPos.begin()->second;