Skip to content

Conversation

Jibola
Copy link
Contributor

@Jibola Jibola commented Sep 8, 2025

TODO

  • Expand queryoptimizer to include getfield support.

@Jibola Jibola changed the base branch from main to expr-conversion-poc September 8, 2025 11:13
@timgraham timgraham force-pushed the expr-conversion-poc branch 2 times, most recently from b99aba3 to 94eefad Compare September 8, 2025 11:44
Base automatically changed from expr-conversion-poc to main September 8, 2025 12:21
expr = {
"$expr": {
"$gt": [
{"$getField": {"input": "$price", "field": "value"}},
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we optimize this down to remove the $getField when the field names don't contain $ or .? Something like:

{  
  "$match": {  
    "$expr": {  
      "$gt": ["$price.value", "$discounted_price.value"]  
    }  
  }  
}  

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could. I'm trying to think if there's any case where this would be an issue if it mistakenly resolved it.

Copy link
Contributor Author

@Jibola Jibola Sep 8, 2025

Choose a reason for hiding this comment

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

This would have to be a two-phase conversion. I think it may even be best to still change it in our actual query code.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming here that this change ends up being needed. Holding off until we either get customer complaints or the refactor can't solve this makes more sense to me for now.

Copy link
Contributor Author

@Jibola Jibola Sep 8, 2025

Choose a reason for hiding this comment

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

Yeah, I tried to make it work (and I think I managed to), but the silent mutation of $getField to $field is worrying to me. Even if I manage to make things pass tests, it just feels out of scope of the optimizers goal, which is to explicitly change things from $expr to $match.

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