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

allow RQL geo args to be strings #6934

Merged
merged 2 commits into from
Aug 31, 2023
Merged

allow RQL geo args to be strings #6934

merged 2 commits into from
Aug 31, 2023

Conversation

ironage
Copy link
Contributor

@ironage ironage commented Aug 30, 2023

The SDKs who use the CAPI do not have support for passing geospatial objects as arguments to the query parser. It is not trivial to enable that and so that work was postponed to geospatial phase 2 which has since been deprioritized. This PR enables this by allowing SDKs to pass the geo object as a serialized string instead which is then parsed by core and the geo object reconstructed. In an ideal world, this problem would be solved by the binding generator, but given our timelines this should work as a temporary solution.

Also see this comment in the scope as to why a proper solution in the CAPI support was not implemented.

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)
  • C-API, if public C++ API changed.

throw InvalidQueryError(util::format(
"Invalid syntax in serialized geospatial object at argument %1: '%2'", arg_no, doctored_err));
}
if (GeoWithinNode* node = dynamic_cast<GeoWithinNode*>(sub_driver.result)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why these checks and why not static_cast? If parsing is successful we should be good here, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like the dynamic cast because if the code structure changes in the future (such that parsing is successful but something other than a GeoWithinNode is produced) and the maintainer forgets to update this code path then the queries fail in a controlled manner rather than aborting the program.

Copy link
Contributor

Choose a reason for hiding this comment

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

You could use the usual trick by adding a dynamic_cast in an assert statement afterwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated!

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.

Added a few comments

@@ -797,12 +797,49 @@ Query GeoWithinNode::visit(ParserDriver* drv)
else {
size_t arg_no = size_t(strtol(argument.substr(1).c_str(), nullptr, 10));
auto right_type = drv->m_args.is_argument_null(arg_no) ? DataType(-1) : drv->m_args.type_for_argument(arg_no);
if (right_type != type_Geospatial) {

Geospatial geo;
Copy link
Contributor

Choose a reason for hiding this comment

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

Hides member variable geo. Confusing. Perhaps the member should be geo_node or geospatial,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good eye, that is confusing. Updated.

@@ -797,12 +797,49 @@ Query GeoWithinNode::visit(ParserDriver* drv)
else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why else here? There is a return above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. I restructured this to simplify the structure.

@ironage
Copy link
Contributor Author

ironage commented Aug 31, 2023

Test failures are unrelated.

@ironage ironage merged commit c258e26 into master Aug 31, 2023
2 checks passed
@ironage ironage deleted the js/parse-geo-string-args branch August 31, 2023 20:29
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants