-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: Avoid throw exception in toSubfieldFilter #15359
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for meta-velox canceled.
|
ff4102a to
ececba2
Compare
|
Can we add a bool flag or another function (e.g. |
|
@Yuhta This function already returns null in some cases (with implicit error) and in Axiom this error anyway ignored. Are any other usages where this information is used? |
ececba2 to
1802bf8
Compare
1802bf8 to
a6dba3a
Compare
|
@MBkkt Ideally null should be returned only for unsupported expression (valid expression that cannot be converted to single field filters). For invalid expression, we should fail early as soon as we can (unless there is some reason preventing us from doing so). |
|
@Yuhta ok, sounds reasonable to me, I will change this |
|
@Yuhta I think for this PR only for unsupported expressions null returned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, this method is a little weird and very limited. Ideally people usually do is to extract a list of filters from a conjunctive expression. It seems this method was created only for testing purpose so the behavior is a little weird. We may need to revisit this method and exam where it is used later.
| const core::TypedExprPtr& expr, | ||
| core::ExpressionEvaluator* evaluator) { | ||
| if (auto call = asCall(expr.get())) { | ||
| if (call->name() == "or") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should remove the logic for handling "or"... I don't think Axiom expects that logic.
Yuhta
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed with @mbasmanova and we probably should document this method first to make the behavior and intended usage clear before changing it.
mbasmanova
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This API is not documented. Let's document it before / at the same time as making changes to it. Also, see #15384
| if (!right.second) { | ||
| return {}; | ||
| } | ||
| if (left.first != right.first) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make sure to add tests for this logic.
| } | ||
| VELOX_UNSUPPORTED( | ||
| "Unsupported expression for range filter: {}", expr->toString()); | ||
| return {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be clearer to change return type to std::optional and return std::nullptr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's worse.
What is semantics of nullptr filter in such case?
Why?
Because in Axiom now code written like this
it's not only ineffective, it's inconvenient to debug (you cannot use break on throw, because this function will throw even when everything fine)