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

feat(bigquery): add dataset samples to cloud-client (2/3) #10035

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

alarconesparza
Copy link
Contributor

@alarconesparza alarconesparza commented Mar 3, 2025

Description

Part of internal b/394478489

Second part of bigquery cloud-client (2/3).

(#10034, #10035, #10036)

This part adds samples 1, 3 and 5 from the following list:

Samples

  1. bigquery_view_dataset_access policy
  2. bigquery_view_table_or_view_access_policy
  3. bigquery_grant_access_to_dataset
  4. bigquery_grant_access_to_table_or_view
  5. bigquery_revoke_dataset_access
  6. bigquery_revoke_access_to_table_or_view

Some of the samples are part of java-bigquery/.../bigquery repo, but are deprecated or the content does not match the docs.

Checklist

  • I have followed Sample Format Guide
  • pom.xml parent set to latest shared-configuration
  • Appropriate changes to README are included in PR
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • Tests pass: mvn clean verify required
  • Lint passes: mvn -P lint checkstyle:check required
  • Static Analysis: mvn -P lint clean compile pmd:cpd-check spotbugs:check advisory only
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

@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 Mar 3, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @alarconesparza, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request adds new samples to the Google Cloud BigQuery Cloud Client library. Specifically, it includes samples for viewing, granting, and revoking dataset access policies. The changes include a new pom.xml file for managing dependencies, as well as three new Java files (GetDatasetAccessPolicy.java, GrantAccessToDataset.java, and RevokeDatasetAccess.java) containing the sample code. Additionally, integration tests are added for each of these samples to ensure they function correctly.

Highlights

  • New Samples: Adds samples for viewing, granting, and revoking dataset access policies in BigQuery.
  • Dependency Management: Introduces a pom.xml file to manage dependencies for the new samples.
  • Integration Tests: Includes integration tests to verify the functionality of the added samples.

Changelog

Click here to see the changelog
  • bigquery/cloud-client/snippets/pom.xml
    • Added a new pom.xml file to manage dependencies for the BigQuery Cloud Client snippets.
    • Configured dependencies for google-cloud-bigquery, junit, and truth.
  • bigquery/cloud-client/snippets/src/main/java/com/example/bigquery/GetDatasetAccessPolicy.java
    • Created a new Java file GetDatasetAccessPolicy.java to demonstrate how to view the access policy of a BigQuery dataset.
    • Includes code to initialize a BigQuery client, retrieve a dataset, and print its ACL details.
    • Uses the [START bigquery_view_dataset_access_policy] and [END bigquery_view_dataset_access_policy] tags to mark the sample code.
  • bigquery/cloud-client/snippets/src/main/java/com/example/bigquery/GrantAccessToDataset.java
    • Created a new Java file GrantAccessToDataset.java to demonstrate how to grant access to a BigQuery dataset.
    • Includes code to initialize a BigQuery client, retrieve a dataset, and add a new ACL entry to grant access to a group.
    • Uses the [START bigquery_grant_access_to_dataset] and [END bigquery_grant_access_to_dataset] tags to mark the sample code.
  • bigquery/cloud-client/snippets/src/main/java/com/example/bigquery/RevokeDatasetAccess.java
    • Created a new Java file RevokeDatasetAccess.java to demonstrate how to revoke access to a BigQuery dataset.
    • Includes code to initialize a BigQuery client, retrieve a dataset, and remove an ACL entry to revoke access to a group.
    • Uses the [START bigquery_revoke_dataset_access] and [END bigquery_revoke_dataset_access] tags to mark the sample code.
  • bigquery/cloud-client/snippets/src/test/java/com/example/bigquery/GetDatasetAccessPolicyIT.java
    • Created a new integration test file GetDatasetAccessPolicyIT.java for the GetDatasetAccessPolicy sample.
    • Includes setup and teardown methods to create and delete a dataset for testing.
    • Verifies that the sample code prints the expected output containing the dataset's ACLs.
  • bigquery/cloud-client/snippets/src/test/java/com/example/bigquery/GrantAccessToDatasetIT.java
    • Created a new integration test file GrantAccessToDatasetIT.java for the GrantAccessToDataset sample.
    • Includes setup and teardown methods to create and delete a dataset for testing.
    • Verifies that the sample code successfully updates the dataset's ACLs.
  • bigquery/cloud-client/snippets/src/test/java/com/example/bigquery/RevokeDatasetAccessIT.java
    • Created a new integration test file RevokeDatasetAccessIT.java for the RevokeDatasetAccess sample.
    • Includes setup and teardown methods to create and delete a dataset, and grant access to a group, for testing.
    • Verifies that the sample code successfully revokes access to the specified group.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


In BigQuery's realm, where data resides,
Access control, a crucial guide.
Granting and revoking, with policies defined,
Securing datasets, for insights aligned.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request adds new samples for managing BigQuery dataset access policies. The code is generally well-structured and follows common Java conventions. However, there are a few areas that could be improved, such as the copyright year and the addition of a README.md file.

Summary of Findings

  • Copyright Year: The copyright year in the license headers is set to 2025. Please confirm that this is the correct year, or update it to the current year if appropriate.
  • Missing README.md: A README.md file is missing in the bigquery/cloud-client/snippets/ directory. Please add a README.md file to explain how to run the samples, what they do, and any prerequisites.

Merge Readiness

The pull request is almost ready to be merged. Before merging, please address the copyright year and add a README.md file to the bigquery/cloud-client/snippets/ directory. I am unable to approve this pull request, and recommend that others review and approve this code before merging.

@@ -0,0 +1,70 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
Copyright 2025 Google LLC

Choose a reason for hiding this comment

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

medium

The copyright year is set to 2025. Please confirm that this is the correct year, or update it to the current year if appropriate.

@@ -0,0 +1,66 @@
/*
* Copyright 2025 Google LLC

Choose a reason for hiding this comment

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

medium

The copyright year is set to 2025. Please confirm that this is the correct year, or update it to the current year if appropriate.

@@ -0,0 +1,71 @@
/*
* Copyright 2025 Google LLC

Choose a reason for hiding this comment

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

medium

The copyright year is set to 2025. Please confirm that this is the correct year, or update it to the current year if appropriate.

@@ -0,0 +1,76 @@
/*
* Copyright 2025 Google LLC

Choose a reason for hiding this comment

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

medium

The copyright year is set to 2025. Please confirm that this is the correct year, or update it to the current year if appropriate.

@@ -0,0 +1,82 @@
/*
* Copyright 2025 Google LLC

Choose a reason for hiding this comment

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

medium

The copyright year is set to 2025. Please confirm that this is the correct year, or update it to the current year if appropriate.

@@ -0,0 +1,87 @@
/*
* Copyright 2025 Google LLC

Choose a reason for hiding this comment

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

medium

The copyright year is set to 2025. Please confirm that this is the correct year, or update it to the current year if appropriate.

@@ -0,0 +1,89 @@
/*
* Copyright 2025 Google LLC

Choose a reason for hiding this comment

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

medium

The copyright year is set to 2025. Please confirm that this is the correct year, or update it to the current year if appropriate.

@alarconesparza alarconesparza changed the title feat(bigquery): add dataset samples to cloud-client feat(bigquery): add dataset samples to cloud-client (2/3) Mar 3, 2025
@alarconesparza alarconesparza marked this pull request as ready for review March 11, 2025 19:48
@alarconesparza alarconesparza requested review from yoshi-approver and a team as code owners March 11, 2025 19:48
Copy link

snippet-bot bot commented Mar 11, 2025

Here is the summary of changes.

You are about to add 3 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

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.

2 participants