Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

identify the identify the user updated the table

I have a dataset and couple to tabes in BigQuery, One of the table has been updated by the random user.
what is the SQL command to find the user and the query ran to update the table?

Solved Solved
1 1 180
1 ACCEPTED SOLUTION

Hi @sharontmathew , 

I hope I can help you with this information. To access the change log in Bigquery you have to access the JOBS View in this way:

 

SELECT
  user_email,
  job_id,
  creation_time,
  end_time,
  query
FROM
  `your_project_id.region-us.INFORMATION_SCHEMA.JOBS_BY_PROJECT`
WHERE
  job_type = 'QUERY'
  AND state = 'DONE'
  AND query LIKE '%UPDATE your_table_name%'
ORDER BY
  creation_time DESC

 

This query filters the Jobs in INFORMATION_SCHEMA.JOBS_BY_PROJECT  to find queries that updated the table you mention (UPDATE your_table_name).

Here the reference documentation :

https://cloud.google.com/bigquery/docs/information-schema-jobs?hl=es-419#required_role 

 

View solution in original post

1 REPLY 1

Hi @sharontmathew , 

I hope I can help you with this information. To access the change log in Bigquery you have to access the JOBS View in this way:

 

SELECT
  user_email,
  job_id,
  creation_time,
  end_time,
  query
FROM
  `your_project_id.region-us.INFORMATION_SCHEMA.JOBS_BY_PROJECT`
WHERE
  job_type = 'QUERY'
  AND state = 'DONE'
  AND query LIKE '%UPDATE your_table_name%'
ORDER BY
  creation_time DESC

 

This query filters the Jobs in INFORMATION_SCHEMA.JOBS_BY_PROJECT  to find queries that updated the table you mention (UPDATE your_table_name).

Here the reference documentation :

https://cloud.google.com/bigquery/docs/information-schema-jobs?hl=es-419#required_role