Я экспортирую платежные данные из Google Cloud Platform в BigQuery (BQ).Задача состоит в том, чтобы создать запрос, который UNNEST относит данные к новой «плоской» таблице. Структура данных в BQ такова:
[{
"billing_account_id": "01234-1778EC-123456",
"service": {
"id": "2062-016F-44A2",
"description": "Maps"
},
"sku": {
"id": "5D8F-0D17-AAA2",
"description": "Google Maps"
},
"usage_start_time": "2018-11-05 14:45:00 UTC",
"usage_end_time": "2018-11-05 15:00:00 UTC",
"project": {
"id": null,
"name": null,
"labels": []
},
"labels": [],
"system_labels": [],
"location": null,
"export_time": "2018-11-05 21:54:09.779 UTC",
"cost": "5.0",
"currency": "EUR",
"currency_conversion_rate": "0.87860000000017424",
"usage": {
"amount": "900.0",
"unit": "seconds",
"amount_in_pricing_units": "0.00034674063800277393",
"pricing_unit": "month"
},
"credits": "-1.25",
"invoice": {
"month": "201811"
}
},
Я хочупланировать работу, которая каждый день строит новую таблицу только с этой схемой
billing_account_id, usage_start_time, usage_end_time, cost, credit_amount
Пока я нахожусь в этом:
select billing_account_id, usage_start_time, usage_end_time, cost, credits AS CREDITS from clientBilling.gcp_billing_export_v1_XXXX , UNNEST(credits);
Но в результате кредиты по-прежнемувложенный и не «плоский», как мне нужно.Любой вклад приветствуется, спасибо!:)
Результат