google-bigquery

Fill with zeros in a frequency of dates group by month and year in big query

三世轮回 提交于 2021-02-11 13:57:05
问题 I have a table with hiredate (Date) ,First Name (String) and Sur Name (string) like this: hireDate First Name Surname 13-oct-14 Cintia Roxana Padilla Julca 28-oct-14 Conor McAteer 28-oct-14 Paolo Mesia Macher 28-oct-14 William Anthony Whelan 15-nov-14 Peter Michael Coates 13-feb-15 Natalie Conche 15-mar-15 Beatriz Vargas Huanca 01-may-15 Walter Calle Chenccnes 04-may-15 Sarah Louise Price And I made a view of a frequency of hire_dates(DATE) and the cumulative frequency in the other column

BigQuery: Select most recent of group of rows with ARRAY type field

风格不统一 提交于 2021-02-11 13:43:24
问题 I have a table with 3 columns: String, Datetime, ARRAY(). Name | LastLogin | FavoriteNumbers Paul | "2019-03-03T06:29:35" | (1, 3, 6, 8) Paul | "2019-03-03T02:29:35" | (1, 3, 6, 8) Paul | "2019-03-01T01:29:35" | (1, 3, 6, 8) Anna | "2019-03-03T02:29:35" | (1, 2, 3, 4) Anna | "2019-03-03T01:29:35" | (1, 2, 3, 4) Maya | "2019-03-02T10:29:35" | (9, 11, 13, 8) This is the result I want: Paul | "2019-03-03T06:29:35" | (1, 3, 6, 8) Anna | "2019-03-03T02:29:35" | (1, 2, 3, 4) Maya | "2019-03-02T10

How to convert strings into column names in Google Bigquery?

折月煮酒 提交于 2021-02-11 13:31:00
问题 I have a large data set in Google Bigquery with millions of rows of dirty data (App tracking) that I am trying to clean up. One of my problems is that the same data got sent to different columns for different events triggered in the App. By this I mean that maybe the country was sent to custom dimension 1 for some events, but to custom dimension 147 for other events. I can't post actual data, but a SELECT * FROM table_with_dirty_data would produce something like this: date | session |

How to convert strings into column names in Google Bigquery?

好久不见. 提交于 2021-02-11 13:30:44
问题 I have a large data set in Google Bigquery with millions of rows of dirty data (App tracking) that I am trying to clean up. One of my problems is that the same data got sent to different columns for different events triggered in the App. By this I mean that maybe the country was sent to custom dimension 1 for some events, but to custom dimension 147 for other events. I can't post actual data, but a SELECT * FROM table_with_dirty_data would produce something like this: date | session |

Using update with Left Join BigQuery

China☆狼群 提交于 2021-02-11 13:28:58
问题 I am trying to write an Update query with LEFT JOIN in BigQuery but I am not sure how to write it. update Table1 set ColumnTest = ifnull(b.value, 'no run') From left join (select distinct ID,value FROM Table2 where value = 10) B -- where Table1.ID= Table2.ID I have 2 tables Table1 and Table2 I want to update Table1.ColumnTest with Table2.Value where Table1.ID= Table2.ID and if Table1 <> Table2 then update Table1.ColumnTest with 'no run' Thanks!! New Try UPDATE Table1 SET LP = IFNULL(t2.value,

Using update with Left Join BigQuery

夙愿已清 提交于 2021-02-11 13:28:12
问题 I am trying to write an Update query with LEFT JOIN in BigQuery but I am not sure how to write it. update Table1 set ColumnTest = ifnull(b.value, 'no run') From left join (select distinct ID,value FROM Table2 where value = 10) B -- where Table1.ID= Table2.ID I have 2 tables Table1 and Table2 I want to update Table1.ColumnTest with Table2.Value where Table1.ID= Table2.ID and if Table1 <> Table2 then update Table1.ColumnTest with 'no run' Thanks!! New Try UPDATE Table1 SET LP = IFNULL(t2.value,

Dataflow SQL - Unsupported type Geography

南笙酒味 提交于 2021-02-11 13:15:58
问题 I'm trying to create a Dataflow SQL on Google Big Query and I got this error Unsupported type for column centroid.centroid: GEOGRAPHY I couldnt find any evidence that Dataflow SQL actually does not support Geography data and in the documentation geography data is not mentioned at all. Is this the case, why is that and is there any workaround? 回答1: No unfortunately Dataflow SQL does not support Geography types. It supports a subset of BigQuery Standard SQL. Only the data types listed

Dataflow SQL - Unsupported type Geography

三世轮回 提交于 2021-02-11 13:11:44
问题 I'm trying to create a Dataflow SQL on Google Big Query and I got this error Unsupported type for column centroid.centroid: GEOGRAPHY I couldnt find any evidence that Dataflow SQL actually does not support Geography data and in the documentation geography data is not mentioned at all. Is this the case, why is that and is there any workaround? 回答1: No unfortunately Dataflow SQL does not support Geography types. It supports a subset of BigQuery Standard SQL. Only the data types listed

fetch key value pairs from array objects in sql BigQuery

牧云@^-^@ 提交于 2021-02-11 12:54:47
问题 I need to parse the column mapping and fetch the key value pairs from the second object in array. I would like to create new columns with the fetched data. The data looks like this: row mapping 1 [{'adUnitCode': ca, 'id': 35, 'name': ca}, {'adUnitCode': hd, 'id': 11, 'name': HD}] 2 [{'adUnitCode': bb, 'id': 56, 'name': jk}, {'adUnitCode': hm, 'id': 12, 'name': HM}] 3 [{'adUnitCode': gh, 'id': 78, 'name': ff}, {'adUnitCode': hk, 'id': 13, 'name': HK}] The desired output: row adUnitCode id name

SQL to get 2 adjacent actions from the flag

百般思念 提交于 2021-02-11 12:50:26
问题 hope you are doing well! I have an dummy data as below. I want to get 2 adjacent actions from the flag by each user. Here's the chart to describe my thought. Here's what I want: How can I implement SQL(I use Google Bigquery)? Hope someone can light me up. Thanks a million! 回答1: You seem to want lag() . I would leave the "action sequence" as two separate columns: select user, prev_action, action, flag from (select t.*, lag(action) over (partition by user order by sequence) as prev_action from