Skip to content

Commit

Permalink
feat(search): add TAGGED as an alternative syntax to HASTAG (#2692)
Browse files Browse the repository at this point in the history
Signed-off-by: PragmaTwice <twice@apache.org>
  • Loading branch information
PragmaTwice authored Dec 12, 2024
1 parent 7cda420 commit 64de844
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/search/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ Note that when interacting with users, we also refer to KQIR as *Kvrocks Search*

- [KQIR: a query engine for Apache Kvrocks that supports both SQL and RediSearch queries](https://kvrocks.apache.org/blog/kqir-query-engine)
- [Index encoding format for Kvrocks Search](https://kvrocks.apache.org/community/kvrocks-search-index-encoding)
- [User documentation of Kvrocks Search](https://kvrocks.apache.org/docs/kvrocks-search)
3 changes: 2 additions & 1 deletion src/search/sql_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ struct StringOrParam : sor<StringL, Param> {};
struct NumberOrParam : sor<Number, Param> {};

struct HasTag : string<'h', 'a', 's', 't', 'a', 'g'> {};
struct HasTagExpr : WSPad<seq<Identifier, WSPad<HasTag>, StringOrParam>> {};
struct Tagged : string<'t', 'a', 'g', 'g', 'e', 'd'> {};
struct HasTagExpr : WSPad<seq<Identifier, WSPad<sor<HasTag, Tagged>>, StringOrParam>> {};

struct NumericAtomExpr : WSPad<sor<NumberOrParam, Identifier>> {};
struct NumericCompareOp : sor<string<'!', '='>, string<'<', '='>, string<'>', '='>, one<'=', '<', '>'>> {};
Expand Down
1 change: 1 addition & 0 deletions tests/cppunit/sql_parser_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ TEST(SQLParserTest, Simple) {
AssertIR(Parse("select a from b where y > 2"), "select a from b where y > 2");
AssertIR(Parse("select a from b where 3 >= z"), "select a from b where z <= 3");
AssertIR(Parse("select a from b where x hastag \"hi\""), "select a from b where x hastag \"hi\"");
AssertIR(Parse("select a from b where x tagged \"hi\""), "select a from b where x hastag \"hi\"");
AssertIR(Parse(R"(select a from b where x hastag "a\nb")"), R"(select a from b where x hastag "a\nb")");
AssertIR(Parse(R"(select a from b where x hastag "")"), R"(select a from b where x hastag "")");
AssertIR(Parse(R"(select a from b where x hastag "hello , hi")"), R"(select a from b where x hastag "hello , hi")");
Expand Down

0 comments on commit 64de844

Please sign in to comment.