-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: handle parentheses with unary ops #4290
Conversation
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Note Reviews pausedUse the following commands to manage reviews:
WalkthroughThis update introduces several enhancements to the Changes
Sequence Diagram(s)sequenceDiagram
participant Client as SQL Client
participant DB as Database
participant FuncReg as Function Registry
participant MatchesFunc as MatchesFunction
Client->>DB: CREATE TABLE test(id INT, name VARCHAR)
DB-->>Client: Table created
Client->>DB: INSERT INTO test VALUES (1, 'Alice'), (2, 'Bob')
DB-->>Client: Data inserted
Client->>FuncReg: Register MatchesFunction
FuncReg-->>MatchesFunc: Called register
Client->>DB: SELECT * FROM test WHERE name MATCHES 'A.*'
DB->>MatchesFunc: Evaluate pattern
MatchesFunc-->>DB: Matches result
DB-->>Client: Query result
Client->>DB: DROP TABLE test
DB-->>Client: Table dropped
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
@coderabbitai pause |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- src/common/function/src/function_registry.rs (2 hunks)
- src/common/function/src/scalars/matches.rs (24 hunks)
- tests/cases/standalone/common/select/matches.result (1 hunks)
- tests/cases/standalone/common/select/matches.sql (1 hunks)
Additional comments not posted (26)
tests/cases/standalone/common/select/matches.sql (4)
1-4
: SQL Table Creation Looks Good.The table creation statement for
fox
is correct.
6-13
: SQL Insert Statements Look Good.The insert statements are correct and insert various test cases for the
matches
function.
15-15
: SQL Select Statement Looks Good.The select statement correctly uses the
matches
function to filter rows.
17-17
: SQL Drop Table Statement Looks Good.The drop table statement correctly drops the
fox
table.tests/cases/standalone/common/select/matches.result (4)
1-4
: Result: Table Creation Affects Zero Rows.The table creation statement does not affect any rows, which is expected.
8-15
: Result: Insert Statements Affect Seven Rows.The insert statements correctly affect seven rows.
19-29
: Result: Select Statement Returns Correct Rows.The select statement returns the correct rows based on the
matches
function.
31-33
: Result: Drop Table Affects Zero Rows.The drop table statement does not affect any rows, which is expected.
src/common/function/src/function_registry.rs (2)
25-25
: New Import: MatchesFunctionThe
MatchesFunction
has been correctly imported.
90-91
: Registering MatchesFunctionThe
MatchesFunction
is correctly registered in the function registry.src/common/function/src/scalars/matches.rs (16)
36-36
: New Import: FunctionRegistryThe
FunctionRegistry
has been correctly imported.
42-42
: Visibility Change: MatchesFunctionThe
MatchesFunction
struct is nowpub(crate)
, which is appropriate for internal use.
44-48
: New Method: registerThe
register
method correctly registers theMatchesFunction
in theFunctionRegistry
.
144-153
: New PatternAst Variant: GroupThe
PatternAst
enum now includes aGroup
variant to represent sub-trees enclosed by parentheses. This change is necessary to handle parentheses with unary operations.
193-200
: Handling Group Variant in into_like_exprThe
into_like_expr
method correctly handles the newGroup
variant.
253-253
: Handling Group Variant in collapse_binary_branch_fnThe
collapse_binary_branch_fn
method correctly handles the newGroup
variant.
303-303
: Handling Group Variant in eliminate_optional_fnThe
eliminate_optional_fn
method correctly handles the newGroup
variant.
364-364
: Handling Group Variant in eliminate_single_child_fnThe
eliminate_single_child_fn
method correctly handles the newGroup
variant.
390-390
: Handling Group Variant in TreeNode ImplementationThe
TreeNode
implementation forPatternAst
correctly handles the newGroup
variant.
428-428
: New Method: accomplish_optional_unary_opThe
accomplish_optional_unary_op
method is correctly added to theParserContext
implementation.
453-497
: Implementing accomplish_optional_unary_opThe
accomplish_optional_unary_op
method correctly processes the raw tokens to handle optional unary operations.
508-520
: Handling Unary Operators in to_rpnThe
to_rpn
method correctly handles the newOptional
unary operator.
554-573
: Handling Must Operator in parse_one_implThe
parse_one_impl
method correctly handles theMust
operator.
577-596
: Handling Negative Operator in parse_one_implThe
parse_one_impl
method correctly handles theNegative
operator.
599-622
: Handling Optional Operator in parse_one_implThe
parse_one_impl
method correctly handles theOptional
operator.
697-702
: New Token Variant: OptionalThe
Token
enum now includes anOptional
variant to represent optional unary operations.
Actions performedReviews paused. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4290 +/- ##
==========================================
- Coverage 85.13% 84.88% -0.26%
==========================================
Files 1061 1061
Lines 187834 187974 +140
==========================================
- Hits 159911 159560 -351
- Misses 27923 28414 +491 |
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Others LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I hereby agree to the terms of the GreptimeDB CLA.
Refer to a related PR or issue link (optional)
What's changed and what's your intention?
The one last piece
Checklist
Summary by CodeRabbit
New Features
matches
function for advanced pattern matching in SQL queries.Bug Fixes
Must
,Negative
,Optional
) more effectively in pattern matching.Tests
matches
function.