GOOGLE-PROFESSIONAL-CLOUD-DEVELOPER practice question 15 of 35

Your analytics system executes queries against a BigQuery dataset. The SQL query is executed in batch and passes the contents of a SQL file to the BigQuery CLI. Then it redirects the BigQuery CLI output to another process. However, you are getting a permission error from the BigQuery CLI when the queries are executed. You want to resolve the issue. What should you do?

Full set: 265 questions
Answer options
A: Grant the service account BigQuery Data Viewer and BigQuery Job User roles. Correct answer
B: Grant the service account BigQuery Data Editor and BigQuery Data Viewer roles.
C: Create a view in BigQuery from the SQL query and SELECT* from the view in the CLI.
D: Create a new dataset in BigQuery, and copy the source table to the new dataset Query the new dataset and table from the CLI.
Correct Answer:
A. Grant the service account BigQuery Data Viewer and BigQuery Job User roles.
Explanation

To resolve the permission error, the service account needs two specific sets of permissions. First, to execute any query, it must have the permission to create a job in BigQuery. The BigQuery Job User (roles/bigquery.jobUser) role grants this necessary bigquery.jobs.create permission. Second, for the query to read data from the tables within the dataset, the service account needs permission to access that data. The BigQuery Data Viewer (roles/bigquery.dataViewer) role provides the required bigquery.tables.getData permission. Granting this combination of roles resolves the error by providing the minimum required permissions for the described task.

Why Incorrect

B. This option is incorrect because the BigQuery Data Editor role does not grant the bigquery.jobs.create permission, which is essential for initiating any query job.
C. Creating a view is a workaround that does not fix the root permission issue. The service account would still lack the necessary permissions to query the view.
D. Copying the entire table is an inefficient solution that creates data redundancy and does not address the fundamental lack of permissions on the service account.

References

1. Google Cloud Documentation, BigQuery Access Control, Predefined roles and permissions: This official document details the permissions included in each predefined BigQuery role.

BigQuery Job User (roles/bigquery.jobUser): "Provides permissions to run jobs, including queries... Includes the bigquery.jobs.create permission."

BigQuery Data Viewer (roles/bigquery.dataViewer): "When applied to a dataset, provides read-only access to the dataset's tables and views... Includes the bigquery.tables.getData permission."

BigQuery Data Editor (roles/bigquery.dataEditor): The list of permissions for this role does not include bigquery.jobs.create.

Source: Google Cloud Documentation, "Predefined roles and permissions", cloud.google.com/bigquery/docs/access-control#bigquery.predefined-roles.

2. Google Cloud Documentation, Running batch query jobs: This guide explicitly states the permission required to run a query job.

"To run a query job, you must have the bigquery.jobs.create IAM permission."

Source: Google Cloud Documentation, "Run an interactive or batch query job", cloud.google.com/bigquery/docs/running-queries#requiredpermissions.

Scroll to Top