【发布时间】:2021-03-05 16:03:24
【问题描述】:
我正在使用 fetch 函数获取附加的 JSON 对象,并使用我的 node.js 后端使用以下代码将此 JSON 数据加载到 Bigquery:
await bigquery
.dataset(datasetId)
.table(tableId).insert(JSON_obj)
但不幸的是得到以下错误:
Unhandled rejection PartialFailureError: A failure occurred during this request
JSON 对象
{
"totalResults": 418,
"profileInfo": {
"profileId": "104881487",
"profileName": "All Mobile App Data",
"accountId": "64812694",
"tableId": "ga:105536427",
"internalWebPropertyId": "100521715",
"webPropertyId": "UA-648333494-1"
},
"totalsForAllResults": {
"ga:users": "427",
"ga:totalEvents": "682",
"ga:eventValue": "0"
},
"query": {
"max-results": 1000,
"start-index": 1,
"start-date": "today",
"end-date": "today",
"dimensions": "ga:eventCategory,ga:eventAction,ga:eventLabel,ga:dateHourMinute",
"metrics": [
"ga:users",
"ga:totalEvents",
"ga:eventValue"
],
"ids": "ga:104831427",
"sort": [
"-ga:totalEvents"
]
},
"selfLink": "https://www.googleapis.com/analytics/v3/data/ga?ids=ga:10483467&dimensions=ga:eventCategory,ga:eventAction,ga:eventLabel,ga:dateHourMinute&metrics=ga:users,ga:totalEvents,ga:eventValue&sort=-ga:totalEvents&start-date=today&end-date=today",
"columnHeaders": [
{
"name": "ga:eventCategory",
"columnType": "DIMENSION",
"dataType": "STRING"
},
{
"name": "ga:eventAction",
"columnType": "DIMENSION",
"dataType": "STRING"
},
{
"name": "ga:eventLabel",
"columnType": "DIMENSION",
"dataType": "STRING"
},
{
"name": "ga:dateHourMinute",
"columnType": "DIMENSION",
"dataType": "STRING"
},
{
"name": "ga:users",
"columnType": "METRIC",
"dataType": "INTEGER"
},
{
"name": "ga:totalEvents",
"columnType": "METRIC",
"dataType": "INTEGER"
},
{
"name": "ga:eventValue",
"columnType": "METRIC",
"dataType": "INTEGER"
}
],
"containsSampledData": false,
"id": "https://www.googleapis.com/analytics/v3/data/ga?ids=ga:104831427&dimensions=ga:eventCategory,ga:eventAction,ga:eventLabel,ga:dateHourMinute&metrics=ga:users,ga:totalEvents,ga:eventValue&sort=-ga:totalEvents&start-date=today&end-date=today",
"itemsPerPage": 1000,
"kind": "analytics#gaData",
"rows": [
[
"video_screen",
"click_on_screen",
"false",
"202011190517",
"1",
"32",
"0"
],
[
"video_screen",
"click_on_screen",
"false",
"202011190730",
"1",
"17",
"0"
],
...
【问题讨论】:
-
我们的表的架构是什么?您真的要存储整个 JSON 吗?
-
没错,这是架构: eventCategory STRING NULLABLE eventAction STRING NULLABLE eventLabel STRING NULLABLE dateHourMinute STRING NULLABLE users INTEGER NULLABLE totalEvents INTEGER NULLABLE eventValue FLOAT NULLABLE
标签: node.js google-cloud-platform google-bigquery google-cloud-storage