-
Notifications
You must be signed in to change notification settings - Fork 44
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
samples: Add snippets for sum and avg #480
Conversation
Here is the summary of changes. You are about to add 5 region tags.
This comment is generated by snippet-bot.
|
We discussed this offline, but please see if you can modify the index as part of the test setup Let me know if you need any help with this |
remove index.yaml since indexes are created in code
I added a test fixture to set up indexes but it's getting a permission error:
|
You're right. The IndexAdmin role does not have permissions for operations. Removed the code that tries to wait for the operation. |
Only the Python 3.10 test failed. Perhaps the IndexAdmin role is missing for that project? |
thanks, I opened a request to add the missing permission to that project |
@jlara310 Ok, the permissions have been added and the tests are now passing! |
task3["hours"] = 1 | ||
|
||
tasks = [task1, task2, task3] | ||
client.put_multi(tasks) |
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.
Do datastore samples typically include this set-up part?
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.
Yes, as part of making samples copy-paste-runnable. This matches the style of the Java and Python count() samples, for example.
samples/snippets/snippets.py
Outdated
# Set up sample entities | ||
task1 = datastore.Entity(client.key("Task", 4871162878230528)) | ||
task2 = datastore.Entity(client.key("Task", 5069834475798528)) | ||
task3 = datastore.Entity(client.key("Task", 5081353846521856)) |
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.
Is there any significance to these numbers?
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.
They are randomly generated IDs from the Datastore console. A previous example used task1
, task2
, task3
, but monotonically increasing IDs are an anti-pattern.
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.
it might be worth either mentioning that in a comment, or even using random.random() to generate them in the sample if that would make sense in the context of the code
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.
Good point. Updated the code to let client generate the IDs and added a comment about it.
Add sample snippets for sum and avg aggregation queries.
Two of these snippets depend on the following index:
indexes:
properties:
I added samples/snippets/index.yaml to track the indexes required for the samples.
Fixes #479 🦕