[AIP-160] Approve the filtering AIP. - #473
Conversation
|
@lukesneeringer Just curious - do you know if there are any support libraries that can be used for implementing filter parsers, or do we use the EBNF grammar to roll our own? Also, I think this paragraph sends mixed messages:
Should it say "should follow the common specification for filters discussed here" since CEL filters are brought up as an alternative? |
I believe we have some internal libraries. @TristonianJones would know for sure what they are.
Good point. Fixing. |
|
It would be helpful to have guidance on whether filtering should all be done in a single request field. For example, if one were to add filtering to ListBooks, and we want to allow filtering across publishers (assuming aip.dev/159 is in effect) and expect it to be a commonly filtered attribute of books: May there be a separate May a commonly filtered attribute be done with a repeated field listing values to match, assuming that general filtering that follows the guidance also exists? |
Single field. The way to do filtering on related objects would be something akin to I will add something for this. |
go/filtering is a very similar design, and is implemented internally at cs/cloud/api/filters with a Java library at java/com/google/cloud/api/filter. I'm not sure if it's 100% compliant with the AIP, but if not I think it would be good for them to converge. |
|
The AIP notes:
Is this a requirement? For certain fields, this may not be feasible. In particular, we have some fields in our APIs that are exposed as email addresses externally but converted to Gaia IDs in storage. If a user passes a literal, it would be difficult-to-impossible (and provide questionable value) to try to match that literal against every email address represented by the Gaia IDs we have stored. |
|
@0x4b I've implemented a slightly more opinionated version of the filter EBNF with ANTLR before for grafeas.io. I've heard good things about peg.js as well. @bMacSwigg I would recommend continuing this conversation over internal message boards rather than in public. What you see is compatible with the intent of the original filter design, though there have been some features developed for specific use cases which aren't discussed here |
|
Note: We are bumping approval of this one to May to allow for certain questions that have come up to be resolved. You should be seeing (mostly minor) revisions to this on this PR soon. |
Some of this was discussed over internal channels.
Co-authored-by: bMacSwigg <brian.mcswiggen@gmail.com>
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
|
@bMacSwigg works here, gidget. |
|
I feel that this AIP intrudes into the UX design for a product, instead of narrowly focusing on API design. I read the statement "...therefore it is prudent to use a string field with a structured syntax accessible to a non-technical audience" as implying that this filter expression SHOULD be user-facing. However applications should be able to tailor their UI experience (including how filters are created) based on their own unique set of requirements. Some may need more sophisticated expression syntax for a tech-oriented product (think Common Expression Language. Consumer-facing apps (think your typical shopping portal) probably will limit filtering building to UI dialogs only. Dictating an expression syntax as part of the API will mandate a parser implementation (likely in both FE and BE) and some expensive translation between what the UI presents and what the API takes. And if you do mandate a filter expression syntax, wouldn't it be prudent wait until public domain parsers are available for most languages before making this a requirement? |
| Additionally, when comparing strings for equality, the `*` character denotes | ||
| wildcard syntax; for example, `a = "*.foo"` is true if `a` _ends with_ ".foo". | ||
| Additionally, when comparing strings for equality, services **should** support | ||
| wildcards using the `*` character; for example, `a = "*.foo"` is true if `a` |
There was a problem hiding this comment.
is this intended as a suffix/prefix match only or general wildcard support ? comments on the list filtering design doc seem to suggest only allowing * as a suffix ( i.e. allow only prefix matching ).
There was a problem hiding this comment.
It seems fine to do more, but we probably only want to require prefix/suffix because of subtleties around values with * in them.
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
This is a good point, @garyxue. We have a couple of parsers now, but it would be useful to see if we could open source them. |
There was a problem hiding this comment.
I've only reviewed the changes here, and this is a generally subtle AIP which I know there has been a lot of iteration on. I haven't carefully reviewed everything else, but I trust others have for previous PRs.
| `!=`, `<`, `>`, `<=`, and `>=`. | ||
| Filtering implementations **should** provide the binary comparison operators | ||
| `=`, `!=`, `<`, `>`, `<=`, and `>=` for string, numeric, timestamp, and | ||
| duration fields (but **should not** provide them for booleans or enums). |
There was a problem hiding this comment.
Enums is an interesting one. Some enums are naturally ordered, others aren't. I'm okay with having this here for the moment, but I suspect it's something we may want to tweak over time.
| | `a.b > 42` | True if `a` has a numeric `b` field that is above 42. | | ||
| | `a.b.c = "foo"` | True if `a.b` has a string `c` field that is "foo". | | ||
|
|
||
| Traversal **must** be written using the field names from the resource. If a |
There was a problem hiding this comment.
Field names as specified in the original proto, presumably.
For field masks, the JSON representation performs camel casing... presumably there's nothing equivalent here, at least not yet? (I can see how that state of affairs could lead to some odd query strings - if you specify both a filter and a field mask in a query string, the two could specify the same field in different ways.)
There was a problem hiding this comment.
I actually think our filtering implementations accept both?
There was a problem hiding this comment.
They're supposed to accept both forms
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
|
They all still work here. |
What happens when I need to filter on a related object, is that something not supported by APIs that follow AIP? How should I do: Since According to the documentation I need to have special Instead of allowing This is easy in 1:1 cases. If suddenly a book has multiple authors: Then we suddenly have However, I didn't see any API in |
This issue is intended for public comment, and should remain open through April 24, 2020.