79168101

Date: 2024-11-07 21:20:46
Score: 1
Natty:
Report link

The fastest way to perform this operation is with the TRANSFORM function in Snowflake. This approach is performed in-place, it doesn't require pivoting and grouping the resultset.

WITH orders AS (...)

SELECT
    order_id,
    TRANSFORM(
       parse_json(orders.promo_json_array)::ARRAY,
       promo OBJECT -> promo:"PromoCode"
    ) as promo_codes_applied
FROM orders
;

enter image description here

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Teej