Skip to content

Conversation

@MBkkt
Copy link
Collaborator

@MBkkt MBkkt commented Nov 1, 2025

Why?

Because in Axiom now code written like this

    try {
      auto pair = velox::exec::toSubfieldFilter(typedExpr, evaluator);
      if (!pair.second) {
        remainingConjuncts.push_back(std::move(typedExpr));
        continue;
      }
      pushdownConjuncts.push_back(typedExpr);
    } catch (const std::exception&) {
      remainingConjuncts.push_back(std::move(typedExpr));
    }
  }

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)

@MBkkt MBkkt requested review from Yuhta and mbasmanova November 1, 2025 06:04
@netlify
Copy link

netlify bot commented Nov 1, 2025

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit a6dba3a
🔍 Latest deploy log https://app.netlify.com/projects/meta-velox/deploys/6908fcf1bf97580008272663

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 1, 2025
@MBkkt MBkkt force-pushed the mbkkt/fix-to-subfield-filter branch from ff4102a to ececba2 Compare November 1, 2025 13:00
@Yuhta
Copy link
Contributor

Yuhta commented Nov 3, 2025

Can we add a bool flag or another function (e.g. toSubfieldFilterNoThrow) to introduce this behavior? Silently suppressing errors should not be the default behavior.

@MBkkt
Copy link
Collaborator Author

MBkkt commented Nov 3, 2025

@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?

@MBkkt MBkkt force-pushed the mbkkt/fix-to-subfield-filter branch from ececba2 to 1802bf8 Compare November 3, 2025 16:49
@MBkkt MBkkt force-pushed the mbkkt/fix-to-subfield-filter branch from 1802bf8 to a6dba3a Compare November 3, 2025 19:05
@Yuhta
Copy link
Contributor

Yuhta commented Nov 3, 2025

@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).

@MBkkt
Copy link
Collaborator Author

MBkkt commented Nov 3, 2025

@Yuhta ok, sounds reasonable to me, I will change this

@MBkkt
Copy link
Collaborator Author

MBkkt commented Nov 4, 2025

@Yuhta I think for this PR only for unsupported expressions null returned

Copy link
Contributor

@Yuhta Yuhta left a 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.

@Yuhta Yuhta added ready-to-merge PR that have been reviewed and are ready for merging. PRs with this tag notify the Velox Meta oncall and removed ready-to-merge PR that have been reviewed and are ready for merging. PRs with this tag notify the Velox Meta oncall labels Nov 4, 2025
const core::TypedExprPtr& expr,
core::ExpressionEvaluator* evaluator) {
if (auto call = asCall(expr.get())) {
if (call->name() == "or") {
Copy link
Contributor

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.

Copy link
Contributor

@Yuhta Yuhta left a 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.

Copy link
Contributor

@mbasmanova mbasmanova left a 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) {
Copy link
Contributor

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 {};
Copy link
Contributor

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.

Copy link
Collaborator Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants