with cte as (select bucket_name, JSON_EXTRACT_scalar(s3_tags, '$.Key') as tag_key, JSON_EXTRACT_scalar(s3_tags, '$.Value') as tag_value, bucket_mfa_delete_enabled, bucket_policy_serverside_encryption_enabled, bucket_versioning_enabled from upt_cloud_s3_inventory_current cross join unnest ( case when length(tags) > 0 then CAST(json_extract(tags, '$') AS ARRAY(json)) when length(tags) = 0 then CAST(JSON '[null]' AS ARRAY(JSON)) end ) as x(s3_tags)) Select * from cte where tag_key like '%uptycs%'