-
Notifications
You must be signed in to change notification settings - Fork 711
feat: support match_all for multi stream #8608
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
Conversation
PR Code Suggestions ✨Explore these optional code suggestions:
|
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.
Greptile Overview
Summary
This PR enhances the match_all functionality to support multi-stream queries by refactoring the validation logic. The key changes include:
- Simplified validation in mod.rs: Removed complex full-text search field validation and stream setting checks, delegating multi-stream detection to the visitor pattern
- Enhanced MatchVisitor logic: Completely rewrote the visitor to precisely identify unsupported scenarios where match_all is used with joins, multi-table FROM clauses, derived tables, or CTEs
- Improved semantic clarity: Renamed
is_multi_streamtois_support_match_allwith inverted boolean logic for better readability - Comprehensive test coverage: Added extensive tests covering various SQL patterns including joins, subqueries, CTEs, and multi-table scenarios
The implementation now correctly allows match_all within subqueries while preventing its use in complex multi-stream scenarios that would be difficult to optimize.
Confidence Score: 4/5
- This PR is safe to merge with minimal risk, containing well-tested logic improvements
- Score reflects solid implementation with comprehensive test coverage and clear logic, with only a minor typo found
- No files require special attention - the implementation is well-structured and thoroughly tested
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| src/service/search/sql/mod.rs | 4/5 | Simplified match_all validation logic by removing full-text search field checks and relying on visitor pattern for multi-stream detection |
| src/service/search/sql/visitor/match_all.rs | 5/5 | Enhanced match_all visitor with comprehensive multi-stream detection logic and extensive test coverage for various SQL scenarios |
Sequence Diagram
sequenceDiagram
participant Client
participant SQL_Parser as SQL Parser
participant MatchVisitor as Match Visitor
participant MatchAllDetector as Match All Detector
participant ValidationEngine as Validation Engine
Client->>SQL_Parser: Parse SQL Query with match_all()
SQL_Parser->>MatchVisitor: Create MatchVisitor instance
MatchVisitor->>MatchVisitor: Initialize is_support_match_all = true
SQL_Parser->>MatchVisitor: Visit AST expressions
MatchVisitor->>MatchAllDetector: Check if expression contains match_all()
MatchAllDetector-->>MatchVisitor: Return has_match_all = true/false
SQL_Parser->>MatchVisitor: Visit query structure
MatchVisitor->>MatchVisitor: Check for joins (FROM table1 JOIN table2)
MatchVisitor->>MatchVisitor: Check for multi-table FROM (FROM table1, table2)
MatchVisitor->>MatchVisitor: Check for derived tables (FROM (subquery))
MatchVisitor->>MatchVisitor: Check for CTEs (WITH clause)
alt Multi-stream query with match_all in WHERE clause
MatchVisitor->>MatchVisitor: Set is_support_match_all = false
else Single stream or match_all in subquery
MatchVisitor->>MatchVisitor: Keep is_support_match_all = true
end
MatchVisitor-->>SQL_Parser: Return validation results
SQL_Parser->>ValidationEngine: Check is_support_match_all
alt is_support_match_all == false
ValidationEngine-->>Client: Error: match_all() in subquery/join not supported
else is_support_match_all == true
ValidationEngine-->>Client: Query validation successful
end
2 files reviewed, 1 comment
…openobserve into feat-multi-stream-match-all
close #8173