Skip to content
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

PoC: Add MQL translation skeleton #7123

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

PoC: Add MQL translation skeleton #7123

wants to merge 4 commits into from

Conversation

jsflax
Copy link
Contributor

@jsflax jsflax commented Nov 9, 2023

No description provided.

@jsflax jsflax requested a review from jedelbo November 9, 2023 13:33
@jsflax jsflax changed the title Add MQL translation skeleton PoC: Add MQL translation skeleton Nov 9, 2023
@jedelbo jedelbo force-pushed the jf/mql branch 4 times, most recently from 3b74cb4 to 36dab22 Compare November 13, 2023 12:41
Copy link

coveralls-official bot commented Nov 13, 2023

Pull Request Test Coverage Report for Build github_pull_request_285284

  • 264 of 308 (85.71%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on jf/mql at 91.664%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/realm/util/bson/bson.cpp 6 7 85.71%
src/realm/object-store/results.cpp 0 4 0.0%
src/realm/parser/query_bson.cpp 117 156 75.0%
Totals Coverage Status
Change from base Build 1854: 91.7%
Covered Lines: 231504
Relevant Lines: 252558

💛 - Coveralls

@jedelbo jedelbo marked this pull request as ready for review November 13, 2023 14:08
@jedelbo jedelbo requested a review from ironage November 13, 2023 14:14
Copy link
Contributor

@jedelbo jedelbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome

Copy link
Contributor

@ironage ironage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!
A couple suggestions to round things out, but as a prototype, I think it is fine to add this in given that it is an additive change. 👍

case QueryLogicalOperators::$not:
node = m_parse_nodes.create<NotNode>(get_query_node(static_cast<bson::BsonDocument>(value)));
break;
case QueryLogicalOperators::$nor:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably throw something here if it isn't supported?

REALM_ASSERT(value.type() == bson::Bson::Type::Array);
std::vector<QueryNode*> nodes = get_query_nodes(static_cast<bson::BsonArray>(value));
REALM_ASSERT(nodes.size() >= 2);
node = m_parse_nodes.create<AndNode>(nodes[0], nodes[1]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LogicalNode::children is public, so it should be fairly straight forward to append any additional conditions beyond the first two. Same with the handling of "$or" below.

if (logical_operators.count(key)) {
switch (logical_operators[key]) {
case QueryLogicalOperators::$and: {
REALM_ASSERT(value.type() == bson::Bson::Type::Array);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these types of conditions should be throwing "invalid query" or something similar rather than asserting. But not blocking.

)"""");
CHECK(object_results.size() == 0);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you test a few non-happy paths to make sure that a reasonably worded syntax error is thrown?
Suggestions:

  • { "non-existing-property": "something" }
  • { str_col: { $regex: "(?i)a(?-i)cme" } } (non-supported query operator "$regex")
  • { "mal-formed-bson" : }

@jedelbo jedelbo requested a review from ironage November 18, 2023 14:21
Copy link
Contributor

@ironage ironage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jsflax
Copy link
Contributor Author

jsflax commented Nov 20, 2023

Let's not merge this yet.

@jedelbo
Copy link
Contributor

jedelbo commented Jan 5, 2024

@jsflax What is going to happen with this PR?

@jsflax
Copy link
Contributor Author

jsflax commented Jan 5, 2024

Unclear right now– we need to road map this before moving forward with the actual feature.

However, if this is adding enough additional useful stuff, I'd be fine removing the MQL features from the header and then consider merging the rest.

@jedelbo
Copy link
Contributor

jedelbo commented Jan 8, 2024

@jsflax you mean removing the changes to results.hpp? I am not sure what the risk of keeping it would be. I would prefer that we can keep the test.

@jedelbo jedelbo marked this pull request as draft August 26, 2024 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants