Skip to content

Instantly share code, notes, and snippets.

View jthandy's full-sized avatar

Tristan Handy jthandy

View GitHub Profile
order_id first_item
1 {"id":"fa4b6cd3-4719-4b97-848b-7f2025f5e693","quantity":1,"sku":"M900353-SWB-RYL-2","list_price":60.0}
2 {"id":"fa4b6cd3-4719-4b97-848b-7f2025f5e693","quantity":1,"sku":"M900353-SWB-RYL-2","list_price":60.0}
order_id number_of_items
1 2
2 1
with orders as (
select
order_id,
json_extract_path_text(json_text, 'items', true ) as items
from flatten_test
),
numbers as (
select * from numbers
),
order_id item_id quantity sku list_price
1 fa4b6cd3-4719-4b97-848b-7f2025f5e693 1 M900353-SWB-RYL-2 60
1 c39f9474-a278-4162-9cfa-aa068f4e1665 1 F033199-SWB-FWL-1 20
2 fa4b6cd3-4719-4b97-848b-7f2025f5e693 1 M900353-SWB-RYL-2 60
with staged_events as (
select * from {{ ref('snowplow_events_base') }}
),
context as (
select
event_id as root_id,
c.value:data:id::string as id,
collector_tstamp