google-bigquery

Is there a SQL function to expand table?

£可爱£侵袭症+ 提交于 2020-01-21 19:18:07
问题 I vaguely remember there being a function that does this, but I think I may be going crazy. Say I have a datatable, call it table1. It has three columns: column1, column2, column3. The query SELECT * FROM table1 returns all rows/columns from table1. Isn't there some type of EXPAND function that allows me to duplicate that result? For example, if I want to duplicate everything from the SELECT * FROM table1 query three times, I can do something like EXPAND(3) ? 回答1: In BigQuery, I would

Get the Last Access date for all BigQuery tables in a BigQuery Project

喜欢而已 提交于 2020-01-21 16:01:49
问题 I know how to get the date a table was last modified, but not accessed. Is it possible to get the last time a table was read ? Is there query or an API to get this ? 回答1: If you have audit logs in BigQuery, you can write a query like this: WITH tables AS ( SELECT FORMAT("%s.%s.%s", table.projectId, table.datasetId, table.tableId) table , MAX(timestamp) last_access FROM ( SELECT timestamp , protopayload_auditlog.servicedata_v1_bigquery.jobCompletedEvent.job.jobStatistics.referencedTables FROM

Get the Last Access date for all BigQuery tables in a BigQuery Project

纵然是瞬间 提交于 2020-01-21 15:59:49
问题 I know how to get the date a table was last modified, but not accessed. Is it possible to get the last time a table was read ? Is there query or an API to get this ? 回答1: If you have audit logs in BigQuery, you can write a query like this: WITH tables AS ( SELECT FORMAT("%s.%s.%s", table.projectId, table.datasetId, table.tableId) table , MAX(timestamp) last_access FROM ( SELECT timestamp , protopayload_auditlog.servicedata_v1_bigquery.jobCompletedEvent.job.jobStatistics.referencedTables FROM

Grouping records and getting standard deviation intervals for grouped records in BigQuery, getting wrong value

拟墨画扇 提交于 2020-01-19 18:05:22
问题 I have a SQL below which is able to get the interval average of timestamp column grouped by icao_address, flight_number, flight_date. I'm trying to do the same for standard deviation and although I get a figure, it is wrong. The standard deviation that I get back is 14.06 (look at image below to see) while it should be around 1.8. Below is what I'm using for stddev calculation. STDDEV_POP(UNIX_SECONDS(timestamp))as standard_deviation Below is my SQL #standardSQL select DATE(timestamp) as

Grouping records and getting standard deviation intervals for grouped records in BigQuery, getting wrong value

一笑奈何 提交于 2020-01-19 18:05:09
问题 I have a SQL below which is able to get the interval average of timestamp column grouped by icao_address, flight_number, flight_date. I'm trying to do the same for standard deviation and although I get a figure, it is wrong. The standard deviation that I get back is 14.06 (look at image below to see) while it should be around 1.8. Below is what I'm using for stddev calculation. STDDEV_POP(UNIX_SECONDS(timestamp))as standard_deviation Below is my SQL #standardSQL select DATE(timestamp) as

Grouping records and getting standard deviation intervals for grouped records in BigQuery, getting wrong value

試著忘記壹切 提交于 2020-01-19 18:04:28
问题 I have a SQL below which is able to get the interval average of timestamp column grouped by icao_address, flight_number, flight_date. I'm trying to do the same for standard deviation and although I get a figure, it is wrong. The standard deviation that I get back is 14.06 (look at image below to see) while it should be around 1.8. Below is what I'm using for stddev calculation. STDDEV_POP(UNIX_SECONDS(timestamp))as standard_deviation Below is my SQL #standardSQL select DATE(timestamp) as

BigQuery and OAuth2

夙愿已清 提交于 2020-01-19 17:04:31
问题 I'm trying to access Google BigQuery using Service Account approach. My code is as follows: private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport(); private static final JsonFactory JSON_FACTORY = new JacksonFactory(); GoogleCredential credentials = new GoogleCredential.Builder() .setTransport(HTTP_TRANSPORT) .setJsonFactory(JSON_FACTORY) .setServiceAccountId("XXXXX@developer.gserviceaccount.com") .setServiceAccountScopes(BigqueryScopes.BIGQUERY)

execute variable values Google BigQuery

夙愿已清 提交于 2020-01-19 15:37:49
问题 I am trying to execute the value of the variable, but I can't find documentation about it in Google BigQuery. DECLARE SQL STRING; SELECT SQL = CONCAT( "CREATE TABLE IF NOT EXISTS first.rdds_", REPLACE(CAST(T.actime AS STRING), " 00:00:00+00", ""), " PARTITION BY actime ", " CLUSTER BY id ", " OPTIONS( ", " partition_expiration_days=365 ", " ) ", " AS ", "SELECT * ", "FROM first.rdds AS rd ", "WHERE rd.actime = ", "'", CAST(T.actime AS STRING), "'", " AND ", "EXISTS ( ", "SELECT 1 ", "FROM

execute variable values Google BigQuery

99封情书 提交于 2020-01-19 15:35:42
问题 I am trying to execute the value of the variable, but I can't find documentation about it in Google BigQuery. DECLARE SQL STRING; SELECT SQL = CONCAT( "CREATE TABLE IF NOT EXISTS first.rdds_", REPLACE(CAST(T.actime AS STRING), " 00:00:00+00", ""), " PARTITION BY actime ", " CLUSTER BY id ", " OPTIONS( ", " partition_expiration_days=365 ", " ) ", " AS ", "SELECT * ", "FROM first.rdds AS rd ", "WHERE rd.actime = ", "'", CAST(T.actime AS STRING), "'", " AND ", "EXISTS ( ", "SELECT 1 ", "FROM

When accessing Bigquery using Python API, what is the difference of using google client API and gcloud

大兔子大兔子 提交于 2020-01-17 06:54:34
问题 I searched for Python API to interact with google bigquery. And I found two packages provides similar APIs: Google BigQuery Client(Part of Google API Client Package googleapiclient ) and Gcloud package gcloud . Here are the documentation about using these two APIs for Bigquery: Google API Client: googleapiclient https://developers.google.com/resources/api-libraries/documentation/bigquery/v2/python/latest/index.html https://cloud.google.com/bigquery/docs/reference/v2/ Google Cloud package: