Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat(bigquery): create cloud-client samples #13147

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

Conversation

eapl-gemugami
Copy link
Contributor

@eapl-gemugami eapl-gemugami commented Feb 11, 2025

@product-auto-label product-auto-label bot added api: bigquery Issues related to the BigQuery API. samples Issues that are directly related to samples. labels Feb 11, 2025
@eapl-gemugami eapl-gemugami added the snippet-bot:force-run Force snippet-bot runs its logic label Feb 11, 2025
@snippet-bot snippet-bot bot removed the snippet-bot:force-run Force snippet-bot runs its logic label Feb 11, 2025
Copy link

snippet-bot bot commented Feb 11, 2025

Here is the summary of changes.

You are about to add 6 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

Copy link

@hivanalejandro hivanalejandro left a comment

Choose a reason for hiding this comment

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

LGTM

- Change function name and region tag from '_policies' to '_policy', to match documentation
- Add more explanation to how the Access policy is retreived as a list of Access Entries
- Add a validation to check if 'access_entries' has elements
@eapl-gemugami eapl-gemugami added the snippet-bot:force-run Force snippet-bot runs its logic label Feb 11, 2025
@snippet-bot snippet-bot bot removed the snippet-bot:force-run Force snippet-bot runs its logic label Feb 11, 2025
Copy link
Contributor

@davidcavazos davidcavazos left a comment

Choose a reason for hiding this comment

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

It looks like the conftest was copied from https://github.com/googleapis/python-bigquery/blob/main/samples/snippets/conftest.py

Other samples there will eventually have to be moved here so we can keep it mostly intact to avoid breaking other samples when they land here.

bigquery/cloud-client/conftest.py Outdated Show resolved Hide resolved
bigquery/cloud-client/requirements-test.txt Outdated Show resolved Hide resolved
bigquery/cloud-client/requirements-test.txt Outdated Show resolved Hide resolved
bigquery/cloud-client/view_dataset_access_policy.py Outdated Show resolved Hide resolved
bigquery/cloud-client/view_dataset_access_policy.py Outdated Show resolved Hide resolved
bigquery/cloud-client/view_dataset_access_policy.py Outdated Show resolved Hide resolved
bigquery/cloud-client/view_dataset_access_policy.py Outdated Show resolved Hide resolved
bigquery/cloud-client/view_dataset_access_policy_test.py Outdated Show resolved Hide resolved
bigquery/cloud-client/view_dataset_access_policy_test.py Outdated Show resolved Hide resolved
bigquery/cloud-client/view_dataset_access_policy_test.py Outdated Show resolved Hide resolved
- Change typing imports as per PEP-585 and PEP-604
- Remove dependencies for Python < 3.9
- Refactor overriding values
- Remove CLI entry point
- Refactor creating and deleting datasets into a single fixture.
- Refactor reading stdout/stderr to returning the dataset and asserting it has the right name.
- Validate that the dataset was deleted successfully.
- Assert over an Access policy, not the Dataset itself
@eapl-gemugami eapl-gemugami changed the title feat(bigquery): WIP create sample 'view dataset access policy' feat(bigquery): create cloud-client samples Feb 12, 2025
# https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.dataset.AccessEntry

# Get properties for an AccessEntry
if dataset.access_entries:
Copy link
Contributor

Choose a reason for hiding this comment

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

That might be because you're indexing over the first element in the list, so you're trying to iterate over a single value rather than the list itself. Would it work if you try this? (note removing the [0])

for key, value in dataset.access_entries:
    print(key, value)

bigquery/cloud-client/view_dataset_access_policy_test.py Outdated Show resolved Hide resolved
- Leave only one way to print access_entries, and refactor with a for to show all list elements.
- Remove unnecessary validation for deleting dataset.
- Remove unnecessary fixture for a second table when first one could be used to create the view.
- Remove magic value for empty policy.
- Works better when there is an empty AccessEntry list.
Copy link
Contributor

@OremGLG OremGLG left a comment

Choose a reason for hiding this comment

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

LGTM

- Rename 'bigquery_client' to 'client' to make it consistent across samples.
- Add validation for empty bindings list in 'view_table_or_access_policy'.
- Add '_id' suffix to placeholder.
@eapl-gemugami eapl-gemugami marked this pull request as ready for review February 20, 2025 18:33
@eapl-gemugami eapl-gemugami requested review from chalmerlowe and a team as code owners February 20, 2025 18:33
@eapl-gemugami eapl-gemugami merged commit 7bbab3a into GoogleCloudPlatform:main Feb 20, 2025
11 checks passed
@eapl-gemugami eapl-gemugami deleted the paradalicea/bigquery/create-sample/view-access-policy-of-a-dataset branch February 20, 2025 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.