BigQuery

CLI#

Run a query using standard SQL:

bq query --nouse_legacy_sql "select ..."

Or define it in ~/.bigqueryrc (docs):

[query]
--use_legacy_sql=false

[mk]
--use_legacy_sql=false

Splitting string into rows#

with

src as (
  select 1 as visit_id, '123-456' as tx_ids
  union all
  select 2 as visit_id, '789' as tx_ids
)

select
  src.tx_ids,
  tx_ids_unpacked as tx_id_unpacked
from
  src
  left join unnest(split(src.tx_ids, '-')) as tx_ids_unpacked

Etc#