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

alternative for fetch_page query limitation #247

Open
monikasingh20 opened this issue Nov 19, 2019 · 22 comments
Open

alternative for fetch_page query limitation #247

monikasingh20 opened this issue Nov 19, 2019 · 22 comments
Labels
api: datastore Issues related to the googleapis/python-ndb API. priority: p2 Moderately-important priority. Fix may not be included in next release. status: blocked Resolving the issue is dependent on other work. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@monikasingh20
Copy link

monikasingh20 commented Nov 19, 2019

Hi,

In current PY3 version 'fetch_page' or 'fetch_page_async' can't be used with query that uses 'OR', '!=', or 'IN'

But it works perfectly in PY27 ndb library.

As I found in previous issue that it's a feature degradation.
So, is there any alternative for it or any way to use fetch_page with 'OR', "!=", "IN" ?
As this feature supports in python2.7, so why can't we have such feature in python3.7 ?? urgent requirement.

@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Nov 20, 2019
@andrewsg
Copy link
Contributor

Thanks for your bug report. I've looked into this and apparently it's a backend issue that the Firestore/Datastore team is working on right now. As soon as that's ready we'll add support for it in the library. Thanks for your patience.

In the meantime, limit and offset should still be usable for these features.

@monikasingh20
Copy link
Author

Thanks! for your response.
Can we expect any tentative ETA for this feature?

@andrewsg
Copy link
Contributor

I didn't receive one from the Firestore team, sorry. Hopefully I'll hear more after the holiday.

@andrewsg andrewsg added status: blocked Resolving the issue is dependent on other work. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Nov 26, 2019
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. triage me I really want to be triaged. 🚨 labels Nov 26, 2019
@monikasingh20
Copy link
Author

Thanks!! hope to hear from you soon.

@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. 🚨 labels Dec 7, 2019
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. 🚨 labels Dec 12, 2019
@andrewsg
Copy link
Contributor

The update I received from the Firestore team yesterday was that we've successfully implemented some of these queries on Firestore native mode, but that the Datastore mode change is pending behind some other related Datastore query work and may take significant additional time. I would strongly recommend switching to limit and offset for now.

@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. 🚨 labels Apr 21, 2020
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label May 17, 2020
@danoscarmike danoscarmike added the api: datastore Issues related to the googleapis/python-ndb API. label May 26, 2020
@crwilcox
Copy link
Collaborator

Thanks again @monikasingh20 for raising this. We are still blocked on implementation of In/Not-in queries for Cloud Datastore. This incompatibility with the Python 2 version is called out in documentation to hopefully help users work around this. https://googleapis.dev/python/python-ndb/latest/query.html#google.cloud.ndb.query.Query.fetch_page

This feature is being added to Cloud Datastore however I don't have a timeline for when it will be released at this time.

@crwilcox crwilcox added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed 🚨 This issue needs some love. 🚨 type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Oct 12, 2020
@punitaojha
Copy link

punitaojha commented Oct 26, 2020

Hello @crwilcox, do we have any latest updates on the same. I was waiting if I could use it.

@crwilcox
Copy link
Collaborator

I still don't have a firm timeline, though it is likely sometime next year.

@denisgrenader
Copy link

HI @crwilcox -- any news on this front?

@kkroening
Copy link

kkroening commented Aug 18, 2021

What seems to make this challenging is that ndb currently has to run multiple queries in parallel in order to support IN/OR/!= queries, and the _MultiQueryIteratorImpl doesn't currently know how to deal with the fact that it's managing multiple sub-query cursors. I suspect that there could be a way to work around this by having _MultiQueryIteratorImpl.{cursor_before,cursor_after} simply combine the cursors by concatenating all the sub-query cursor values, and then having _MultiQueryIteratorImpl.__init__ do the reverse by unpacking the start_cursor.

From an external perspective, the _MultiQueryIteratorImpl would look just like any other QueryIterator implementation, accepting a seemingly-ordinary start_cursor and producing seemingly-ordinary cursor_before() and cursor_end() values, but in fact, these cursors would contain all of the sub-query cursors essentially multiplexed together.

Just an idea; not sure if there's any reason that this wouldn't work. Of course, if Datastore/Firestore itself eventually natively supports IN/OR/!=, then this becomes moot, but it could be a while before that happens and ndb gets updated to use it, and the datastore emulator is updated as well - so perhaps if someone's bored, it might be worth trying this out, at least as a science experiment to see if it's a viable approach.

@jacobg
Copy link

jacobg commented Oct 1, 2021

@crwilcox Is support for this type of query still in the works? Thanks.

@neurino
Copy link

neurino commented Aug 4, 2022

Hello, any update on this topic? This is very limiting: using IN of course returns more results and thus needs pagination :(

@meredithslota
Copy link

Support for IN/NOT_IN/NOT_EQUAL operators was released in Cloud Datastore in https://github.com/googleapis/python-datastore/releases/tag/v2.7.0, if that's helpful.

@pacssee
Copy link

pacssee commented Sep 23, 2022

Still getting this error with google-cloud-datastore==2.7.0:
TypeError: Can't use 'fetch_page' or 'fetch_page_async' with query that uses 'OR', '!=', or 'IN'.

Also, google-cloud-ndb 1.11.1 (current version) has requirement google-cloud-datastore<2.0.0dev,>=1.7.0 which makes it incompatible with 2.7.0

@rwhogg
Copy link
Contributor

rwhogg commented Dec 6, 2022

We recently upgraded our dependencies, so now we depend on at least google-cloud-datastore 2.7.2.

@michaelkariv
Copy link

michaelkariv commented Apr 3, 2023

What is the latest on this? I rely on IN for my Py2 GAE code, have to migrate because of the py2 GAE end of life early next year.
UPDATE 2023-04-04, I have updated google-cloud-ndb to the currently latest 2.1.1, and it updated google-cloud-datastore to the currently latest (per pip) 2.15.1. Still get the error.

@JohnGale87
Copy link
Contributor

Please can we have an update on this issue?

@JohnGale87
Copy link
Contributor

Still looking for an update on this issue, any news?

@sorced-jim
Copy link
Contributor

Not complete fixes, but #951 & #950 allow supporting != & IN (within the server limits) for fetch_page.

@tlatin
Copy link

tlatin commented Mar 4, 2024

@sorced-jim what size is the server limits?

Looks like this went out with the 2.3.0 python-ndb release.

@sorced-jim
Copy link
Contributor

The server side limits are documented at https://cloud.google.com/datastore/docs/concepts/queries#in. It's currently 30.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the googleapis/python-ndb API. priority: p2 Moderately-important priority. Fix may not be included in next release. status: blocked Resolving the issue is dependent on other work. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests