I'm trying to unnest the line_items in my table. However, I have to remove duplicates from our table and it's throwing off what should normally work.
This is the query I use to eliminate duplicates:
SELECT *, ROW_NUMBER() OVER(PARTITION BY id) AS instance
FROM `shopify.orders` )
-- identify duplicate rows
where instance = 1
However, when I try to unnest the line_items in this query, it's no longer able to partition by id
SELECT *, ROW_NUMBER() OVER(PARTITION BY id) AS instance
FROM `shopify.orders`, unnest(line_items) as items )
-- identify duplicate rows
where instance = 1
Any ideas how I can eliminate duplicates while also unnesting the line_items?
Without removing duplicates, this is what my data looks like: