|
@@ -8,9 +8,9 @@
|
|
|
using namespace NSQLTranslation;
|
|
|
using namespace NSQLTranslationV1;
|
|
|
|
|
|
-TSQLHints CollectHints(const TString& query) {
|
|
|
+TSQLHints CollectHints(const TString& query, bool antlr4Parser) {
|
|
|
bool ansi = false;
|
|
|
- auto lexer = MakeLexer(ansi);
|
|
|
+ auto lexer = MakeLexer(ansi, antlr4Parser);
|
|
|
UNIT_ASSERT(lexer);
|
|
|
TSQLHints result;
|
|
|
NYql::TIssues issues;
|
|
@@ -27,7 +27,20 @@ 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);
|
|
|
+ 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);
|
|
|
UNIT_ASSERT(hintsWithPos.size() == 1);
|
|
|
NYql::TPosition pos = hintsWithPos.begin()->first;
|
|
|
TVector<TSQLHint> hints = hintsWithPos.begin()->second;
|