'How to use a filter within STRUCT where JSON_extract is used

I want to filter the array which is structed using json_extract. Specifically, I am using below script to pull data:

select 
       ARRAY(
      SELECT STRUCT(JSON_EXTRACT_SCALAR(loads, '$.barcode') as barcode, JSON_EXTRACT_SCALAR(loads, '$.eventDate') as eventDate) 
      FROM UNNEST(JSON_EXTRACT_ARRAY(payload, "$.JSONDocument.load")) loads
    ) shipment,
 from table
    

and I want to filter JSON_EXTRACT_SCALAR(loads, '$.eventDate'). Any answers is appreciated



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source