Skip to content

Tag: google-bigquery

String array to int64 conversion

I’ve two tables and I need to join them. But the common field are of different data types. Table A – ID field is of string array and Table B ID is of Int64. Tried to cast String array to Int 64 getting error “Invalid cast from ARRAY to INT64” Is there anyway I can convert and join the …

Count Distinct IDs in a date range given a start and end time

I have a BigQuery table like this id start_date end_date location type 1 2022-01-01 2022-01-01 MO mobile 1 2022-01-01 2022-01-02 MO mobile 2 2022-01-02 2022-01-03 AZ laptop 3 2022-01-03 2022-01-03 AZ mobile 3 2022-01-03 2022-01-03 AZ mobile 3 2022-01-03 2022-01-03 AZ mobile 2 2022-01-02 2022-01-03 CA laptop 4…

BigQuery SQL Regex_extract repeated pattern

New to regexp, below is the sample query and our try as below union all select ‘https://www.this-is-pqrs.com/<some_text>/ab.abc.ef.gh.ij/123456.csv’ str union all select ‘https://www.this-is-pqrs.com/<some_text>/ab.abd.ef.gh.ij/123456.csv’ str union all select ‘https:…

Aggregating or nesting STRUCTs in Big Query SQL

I have the following table: ClientId (Integer) EmailCampaign (String) CampaignDetails (STRUCT) 235 Campaign 32 SentOn: 2020-01-22, Email addresses:2, SuccessRate:1 235 Campaign 22 SentOn: 2021-02-02, Email addresses:2, SuccessRate:0.5 235 Campaign 23 SentOn: 2022-05-11, Email addresses:2, SuccessRate:0.3 235 …

BigQuery – SQL UPDATE and JOIN

I have two tables. Table1 = dalio which is an event list with select customers. Table2 = master_list which is a master customer list from all past events. dalio has an “id” column that needs to be filled in with customer numbers, which can be pulled from master_list column called “customer_n…