Conversation
williambdean
left a comment
There was a problem hiding this comment.
Just some comments on how the previous functionality worked
src/frame_search/parse.py
Outdated
| VALUE_DEPENDENT_COMPARATORS = defaultdict( | ||
| lambda: operator.eq, | ||
| { | ||
| str: lambda col, value: col.str.contains(value), |
There was a problem hiding this comment.
I had this using to_lowercase and lower on the string value just to make it easier while using
Column
["Bob", "Bobby", "Billy Bob"]
search("name:bob") # Would work for all
src/frame_search/parse.py
Outdated
| def BARE_KEY(self, token: Token) -> nw.Expr: | ||
| return Column(token.value) |
There was a problem hiding this comment.
The previous behavior treats these not as Column but as a value to match in a default column. For example, having a default column of state allows users to just use search("California") for matches. Those default and columns aliases might be needed in an init of this Transformer
There was a problem hiding this comment.
This might be wrong spot to point this out though
The new grammar introduces standard comparators and
allows the colon comparator to use value-specific comparisons.
The rules are as follows:
- The left side of any comparator is always parsed as a column name
- The right side of any comparator can be a value, or composition of
values
- numeric comparisons can be performed via standard comparators <>=!
- the ":" comparator is value-depdendent
- "x,y,z" (isin) supports checking multiple values
- 2..6 (range) supports numeric/date range comparisons
- "abe" (escaped strings) are lowercase matched
ac8b1f7 to
c4f4e20
Compare
|
Made some updates to flesh out the grammar a bit more. There are two major features that still need to be integrated
Let me know if there is anything else as well that you can find/think of! |
Uses lark to construct a grammar and parser for the query strings.
search.pydef parse→ to return a graph composed ofparse.BinaryOps andSearchNodesdef search→ convenience toparsea query, convert the result to anarwhals.Exprand use it to filter passed in dataTo Do