-
Notifications
You must be signed in to change notification settings - Fork 7
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
add support for partial indexes #159
Conversation
07e5a17
to
575957c
Compare
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.
Added some comments! Will circle back and ask some more tomorrow :)
575957c
to
f3d71fc
Compare
After e971120, simple conditions no longer work, but we may need a separate path for generating this MQL anyway.
|
f3d71fc
to
99623ee
Compare
7a03e3a
to
e1233b1
Compare
This comment was marked as resolved.
This comment was marked as resolved.
ff3770a
to
e4f4350
Compare
Can the following be supported? If not, we can edit the test with a condition that is supported.
Also, please add |
Maybe it makes sense to put the |
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.
Please make sure all operators in mongo_operators_idx
are tested. Also, it looks like we may need quite a few tests to cover all the branches in where_node_idx
.
98acdae
to
e2bd68f
Compare
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 is coming along. I pushed some edits in lieu of leaving some comments.
Found a bug in where.as_mql (should rise EmptyResultSet), and also I have to research in which way the test from constraints will be adapted, it isn't straightforward |
Oh, I didn't notice the constraints problems you mentioned previously. I added a Django fork commit to place
The SQL:
I think it fails because in MongoDB, we have no notion of executing a query without a collection. I wonder if we could make it work without the outer query? But it looks tricky because I don't see a place we could hook into to customize the query: https://github.com/django/django/blob/042b381e2e37c0c37b8a8f6cc9947f1a2ebfa0dd/django/db/models/query_utils.py#L117-L151 |
I added like a dummy collection to handle this and created the pr fixing the remaining unit tests. |
840901a
to
d1d9c33
Compare
953e4fc
to
3dcb730
Compare
3dcb730
to
457d428
Compare
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.
Overall, LGTM. Would love clarity on the $facet question
django_mongodb/compiler.py
Outdated
try: | ||
base_table = next( | ||
v | ||
for k, v in self.query.alias_map.items() | ||
if isinstance(v, BaseTable) and self.query.alias_refcount[k] | ||
) | ||
except StopIteration: | ||
# Use a dummy collection if the query doesn't specify a table | ||
# (such as Constraint.validate() with a condition). | ||
query = self.query_class(self) | ||
query.aggregation_pipeline = [{"$facet": {"__null": []}}] | ||
self.subqueries.insert(0, query) | ||
return "__null" |
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.
My one worry here is $facet
is subject to the 16MB document size limit, so in the case of using Constraint
we should note the corner cases and limitations properly. (Especially if this is a blocker for getting partial indexing)
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.
Well, the facet execution will have a very short pipeline, is just a way to insert a document so the subqueries won't get empty.
I mean
just this example:
select 1
where exists(some subquery checking that an index exists)
This is translated as:
[{"$facet": {"__null": []}},
{"$lookup": {"the subquery"}}
{"$match": {"condition to check from the subquery"}}
]
If a query over an empty collection is executed, the result will be 0 rows. To avoid that, I put a single tiny document
176cd33
to
76ca293
Compare
Co-authored-by: Emanuel Lupi <[email protected]>
76ca293
to
84d0f04
Compare
refs #104