google-bigquery

Group by range of values in bigquery

天大地大妈咪最大 提交于 2021-02-08 11:42:17
问题 Is there any way in Bigquery to group by not the absolute value but a range of values? I have a query that looks in a product table with 4 different numeric group by's. What I am looking for is an efficient way to group by in a way like: group by "A±1000" etc. or "A±10%ofA". thanks in advance, 回答1: You can generate a column as a "named range" then group by the column. As an example for your A+-1000 case: with data as ( select 100 as v union all select 200 union all select 2000 union all

How to get Crashlytics event from BigQuery[Firebase project]

非 Y 不嫁゛ 提交于 2021-02-08 11:40:21
问题 We have enabled BigQuery feature for our Firebase project , since last week firebase team announced that Crashlytics is moved from Beta to Prod release , so I was thinking this data should be available in BigQuery in some form. But I was not able to see any Crash event in my BigQuery table even the app crashed a couple of time. So does anybody know how to extract the crashlytics report from Firebase for custom reporting solution. 回答1: Crashlytics data is not currently available in BigQuery

CREATE OR REPLACE TEMP TABLE in a script error: “Exceeded rate limits: too many table update operations for this table.”

霸气de小男生 提交于 2021-02-08 11:31:25
问题 This script gives me an error after ~11 steps: DECLARE steps INT64 DEFAULT 1; LOOP CREATE OR REPLACE TEMP TABLE countme AS (SELECT steps, 1 x, [1,2,3] y); SET steps = steps+1; IF steps=30 THEN LEAVE; END IF; END LOOP; Exceeded rate limits: too many table update operations for this table. For more information, see https://cloud.google.com/bigquery/troubleshooting-errors Even if this is a temp table - what can I do instead? 回答1: Instead of using a TEMP TABLE , hold the results on a temp

BigQuery, fill missing values with Linear interpolation

情到浓时终转凉″ 提交于 2021-02-08 11:25:24
问题 I have a table in Bigquery with data every 30 minutes, I want to show the data every 5 minutes, currently I am using this query to fill the null values with the existing values SELECT SETTLEMENTDATE,DUID, LAST_VALUE(SCADAVALUE ignore nulls) OVER ( PARTITION BY DUID ORDER BY SETTLEMENTDATE) AS SCADAVALUE from x instead, is it possible to do Linear interpolation, something like this I have the column settlement date which is by 5 minutes, the column SCADAVALUEORIGIN Which has a value very 30

Count of overlapping intervals in BigQuery

醉酒当歌 提交于 2021-02-08 10:33:35
问题 Given a table of intervals, can I efficiently query for the number of currently open intervals at the start of each interval (including the current interval itself)? For example, given the following table: start_time end_time 1 10 2 5 3 4 5 6 7 11 19 20 I want the following output: start_time count 1 1 2 2 3 3 5 3 7 2 19 1 On small datasets, I can solve this problem by joining the dataset against itself: WITH intervals AS ( SELECT 1 AS start, 10 AS end UNION ALL SELECT 2, 5 UNION ALL SELECT 3

Updating a table schema while streaming inserts

落爺英雄遲暮 提交于 2021-02-08 10:24:15
问题 I have a table that is continuously receiving streaming inserts (potentially thousands per second). I am interested in using the Update functionality (via API calls) to add a column. Can I call Update to add a column to an existing table, while data is still being inserted, without concern for loss of data? For reference, here is the code I am planning on using to add a column to the table: func addColumnToTable(service *bigquery.Service, project, dataset, table string, newCols map[string

Updating a table schema while streaming inserts

為{幸葍}努か 提交于 2021-02-08 10:22:56
问题 I have a table that is continuously receiving streaming inserts (potentially thousands per second). I am interested in using the Update functionality (via API calls) to add a column. Can I call Update to add a column to an existing table, while data is still being inserted, without concern for loss of data? For reference, here is the code I am planning on using to add a column to the table: func addColumnToTable(service *bigquery.Service, project, dataset, table string, newCols map[string

Insert 1 million records from SQL Server to BigQuery table, linked via CDATA odbc driver

馋奶兔 提交于 2021-02-08 10:22:51
问题 I need to insert 1 million (and more) records from a SQL Server table to a BigQuery table, that is present in SQL Server as "linked server" via CDATA odbc driver with remoting daemon in it (documentation). Also, source table might have no column with number of row, Id etc. For now, I can insert 1 record per second into BigQuery with this driver, using this query: INSERT INTO [GBQ].[CDataGoogleBigQuery].[GoogleBigQuery].[natality] SELECT * FROM [natality].[dbo].[natality] GO But for such a

Google OAuth 2.0 using Python for GCP BigQuery

混江龙づ霸主 提交于 2021-02-08 09:52:05
问题 I am seeking a code snippet for implementing oAuth 2.0 authentication using python to connect to GCP Big Query service. I am using Google cloud shell to write the python code. But the access token I am receiving bad request. access_token = google.fetch_token(token_url=token_url,client_id=client_id,client_secret=client_secret,authorization_response=redirect_response). Also I need to automate this process so manually pasting the redirect_response needs to be avoided. 回答1: It is recommended that

Google OAuth 2.0 using Python for GCP BigQuery

霸气de小男生 提交于 2021-02-08 09:51:39
问题 I am seeking a code snippet for implementing oAuth 2.0 authentication using python to connect to GCP Big Query service. I am using Google cloud shell to write the python code. But the access token I am receiving bad request. access_token = google.fetch_token(token_url=token_url,client_id=client_id,client_secret=client_secret,authorization_response=redirect_response). Also I need to automate this process so manually pasting the redirect_response needs to be avoided. 回答1: It is recommended that