Cardinality of filter compared to zero#13867
Cardinality of filter compared to zero#13867kaikalur wants to merge 1 commit intoprestodb:masterfrom
Conversation
c2440c8 to
9aff6af
Compare
9aff6af to
c9d4bbe
Compare
|
OK so the previous PR was contentious :) so I removed all the complex stuffs and just added a very simple rewrite that uses any_match/none_match for comparing cardinality(filter) to 0. Please check it out. For reference, here is the previous PR: Sorry I couldn't update that PR properly so starting a fresh one. Thanks! |
919b66a to
f9fc221
Compare
f9fc221 to
80bca3d
Compare
| return expression instanceof Literal; | ||
| } | ||
|
|
||
| private static boolean isZero(Expression expression) |
There was a problem hiding this comment.
cc @highker, @hellium01 : Is this the recommended way to see whether a expression will be evaluated into certain constant?
There was a problem hiding this comment.
Not really; we need to use interpreter and evaluate the expression. The return result of the eval should be a const with 0 as its value.
| { | ||
| if (expression instanceof FunctionCall) { | ||
| FunctionCall functionCall = (FunctionCall) expression; | ||
| return functionCall.getName().toString().equals("cardinality") && |
There was a problem hiding this comment.
We used to use resolveFunction to get the function handle. But given now it requires transactions, maybe @rongrong can be a better PoC to comment on.
There was a problem hiding this comment.
resolveFunction now only takes an optional transaction ID. Since this is a static function you can just pass in Optional.empty().
|
This pull request has been automatically marked as stale because it has not had recent activity. If you'd still like this PR merged, please comment on the task, make sure you've addressed reviewer comments, and rebase on the latest master. Thank you for your contributions! |

We rewrite expressions of the CARDINALITY(FILTER(array, lambda)) =/> 0 to none_match/anymatch(array, lambda) for preformance.