-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
spanner/spannertest: support STARTS_WITH #4661
Comments
@olavloite Any thoughts about this? |
By doing the above you would get a solution that would work automatically, as the implementation of |
@olavloite Thanks for the answer. Also, your solution looks fine and I'm trying to implement with that way. Let me ask you a bit about implementing the generic support. |
I'm not entirely sure I understand what you mean by that, but more in general: I don't think you need to (or should) implement function parsing differently for functions that return a
No, that is what I meant, but there seems to be more implemented already than I thought. So there is a bare-bone implementation for functions already, but it's very limited at the moment:
The above means that:
No. Parsing a function should be completely independent of any operators before or after the function itself. The expression that is returned by the parser is added to the evaluation tree, just as the NOT operator that preceded it, and the evaluator is responsible for evaluating the entire tree once all expressions have been parsed. You should think of a function exactly as any other expression, such as for example a constant literal (for example the boolean value Consider the following two statements:
There's nothing different or magical about the |
- Adds support for the STARTS_WITH function. - Adds an example for how further functions can be implemented. Fixes #4661
Thanks for the very clear and detailed explanation 😆 Now I understand the design concept of the SQL parsing for function expression. Also, thanks for #4670. According to your explanation, your solution looks reasonable. |
- Adds support for the STARTS_WITH function. - Adds an example for how further functions can be implemented. Fixes #4661 Co-authored-by: Hengfeng Li <hengfeng@google.com>
…is#4670) - Adds support for the STARTS_WITH function. - Adds an example for how further functions can be implemented. Fixes googleapis#4661 Co-authored-by: Hengfeng Li <hengfeng@google.com>
Is your feature request related to a problem? Please describe.
I suppose
spannertest
doesn't support theSTARTS_WITH
clause yet.It would be great if it's supported.
As the official doc recommends using it rather than
LIKE
for a forward match, there should be certain motivation to use it.Describe the solution you'd like
I tried to implement it, but, due to the following characteristic of
STARTS_WITH
, it looks there is a certain point to consider inspansql
.STARTS_WITH
is a kind of comparison clause same asLIKE
andBETWEEN
But,
Due to the above, we cannot simply parse it as with the other comparison clauses even though what it does is the same as them.
I think there are two implementation options to handle that (I suppose the first one is better).
Op
struct and the parsing func forSTARTS_WITH
.STARTS_WITH
in the same func with the other comparison clauses, and add code in the parent parsing funcs so thatSTARTS_WITH
won't be parsed in the different code.The text was updated successfully, but these errors were encountered: