You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add LIKE operator for pattern matching in WHERE #13
Add support for the LIKE operator in WHERE clauses for simple pattern matching on string columns.
Expected Behavior
SELECT*FROM'users.csv'WHERE name LIKE'John%'SELECT*FROM'data.csv'WHERE email LIKE'%@gmail.com'SELECT*FROM'products.csv'WHERE sku LIKE'AB__CD'
Standard SQL LIKE patterns:
% matches any sequence of characters (including empty)
_ matches exactly one character
Why This Is a Good First Issue
Teaches pattern matching algorithm implementation in Zig
Involves modifying the parser (new operator) and engine (new evaluation logic)
Self-contained — no dependencies on GROUP BY or other pending features
A great exercise in recursive or iterative string matching
Suggested Approach
Add like to the Operator enum in src/parser.zig
Detect LIKE keyword during WHERE clause parsing (between column name and pattern value)
Implement a matchLike(text: []const u8, pattern: []const u8) bool function
The matching function can be iterative: scan pattern left-to-right, _ consumes one char, % tries matching the rest of pattern against every suffix of text
Integrate into WHERE evaluation in src/engine.zig, src/mmap_engine.zig, src/parallel_mmap.zig
Pattern matching pseudocode
fn matchLike(text, pattern) -> bool:
t = 0, p = 0
star_p = -1, star_t = -1
while t < text.len:
if p < pattern.len and (pattern[p] == '_' or pattern[p] == text[t]):
t++, p++
else if p < pattern.len and pattern[p] == '%':
star_p = p, star_t = t, p++
else if star_p >= 0:
star_t++, t = star_t, p = star_p + 1
else:
return false
while p < pattern.len and pattern[p] == '%': p++
return p == pattern.len
Related Files
src/parser.zig — operator enum, WHERE parsing
src/engine.zig — WHERE clause evaluation
src/mmap_engine.zig — WHERE evaluation (mmap path)
src/parallel_mmap.zig — WHERE evaluation (parallel path)
Activity