从 Google Ads BigQuery 数据传输中提取/取消嵌套数组

Extract/ Unnest Arrays from Google Ads BigQuery Data Transfer

我正在尝试提取 JSON 数组中包含的 Unnest 数据,Google 广告通过 BigQuery 数据传输发送。不幸的是,我被卡在了中间。

BigQuery 中的原始数据Table:

CreativeId 响应式搜索广告描述
487067671679 [{"assetText":"SearchAds 描述文本 1","assetId":12443453594,"pinnedField":"DESCRIPTION_1","assetPerformanceLabel":"PENDING","assetApprovalStatus":"已批准"},{"assetText":"SearchAds Description Text 2","assetId":12443453165,"assetPerformanceLabel":"PENDING","assetApprovalStatus":"APPROVED"},{"assetText":"SearchAds Description Text 3", "assetId":12443453168,"assetPerformanceLabel":"PENDING","assetApprovalStatus":"APPROVED"},{"assetText":"SearchAds Description Text 4","assetId":12443419160,"assetPerformanceLabel":"PENDING"," assetApprovalStatus":"已批准"}]

期望的结果:

CreativeId ResponsiveSearchAdDescriptions_assetText ResponsiveSearchAdDescriptions_assetId ResponsiveSearchAdDescriptions_pinnedField ResponsiveSearchAdDescriptions_assetPerformanceLabel ResponsiveSearchAdDescriptions_assetApprovalStatus
487067671679 SearchAds 描述文本 1 12443453594 DESCRIPTION_1 待定 已批准
487067671679 SearchAds 描述文字 2 12443453165 --- 待定 已批准
487067671679 SearchAds 描述文字 3 12443453168 --- 待定 已批准
487067671679 SearchAds 描述文字 4 12443419160 --- 待定 已批准

这是最接近我但仍显示 JSON 的查询。

SELECT
  CreativeId,
  JSON_QUERY_ARRAY(ResponsiveSearchAdDescriptions) AS Ads
FROM
  `priXXXXXX.sandbox.Ad_XXXXXXX`
WHERE
  ResponsiveSearchAdDescriptions IS NOT NULL
LIMIT
  100

查询应该能够包含这个条件ResponsiveSearchAdDescriptions IS NOT NULL

一些想法?

使用以下方法

select Creativeld, 
  json_extract_scalar(el, '$.assetText') as assetText,
  json_extract_scalar(el, '$.assetId') as assetId,
  json_extract_scalar(el, '$.pinnedField') as pinnedField,
  json_extract_scalar(el, '$.assetPerformanceLabel') as assetPerformanceLabel,
  json_extract_scalar(el, '$.assetApprovalStatus') as assetApprovalStatus
from `priXXXXXX.sandbox.Ad_XXXXXXX`,
unnest(json_extract_array(ResponsiveSearchAdDescriptions, '$')) el          

如果应用于您问题中的示例数据 - 输出为