Ниже для BigQuery Standard SQL
#standardSQL
SELECT col,
(
SELECT AS STRUCT CAST(SPLIT(item, ':')[SAFE_OFFSET(1)] AS INT64) age, item
FROM UNNEST(SPLIT(REGEXP_REPLACE(col, r'{|}', ''))) item
ORDER BY CAST(SPLIT(item, ':')[SAFE_OFFSET(1)] AS INT64) DESC
LIMIT 1
).*
FROM `project.dataset.table`
Вы можете протестировать, поиграйте с выше, используя фиктивные данные, как в примере ниже
#standardSQL
WITH `project.dataset.table` AS (
SELECT '{“cat_age”: 14, “dog_age”: 4}' col UNION ALL
SELECT '{“cat_age”: 11, “dog_age”: 16}'
)
SELECT col,
(
SELECT AS STRUCT CAST(SPLIT(item, ':')[SAFE_OFFSET(1)] AS INT64) age, item
FROM UNNEST(SPLIT(REGEXP_REPLACE(col, r'{|}', ''))) item
ORDER BY CAST(SPLIT(item, ':')[SAFE_OFFSET(1)] AS INT64) DESC
LIMIT 1
).*
FROM `project.dataset.table`
с результатом
Row col age item
1 {“cat_age”: 14, “dog_age”: 4} 14 “cat_age”: 14
2 {“cat_age”: 11, “dog_age”: 16} 16 “dog_age”: 16