使用API​​将数据插入BigQuery到日期分区表

时间:2016-09-21 20:13:13

标签: php google-bigquery

我尝试使用分区将数据插入到BigQuery表中。 我总是得到错误:

"errors": [
         {
            "domain": "global",
            "reason": "internalError",
            "message": "An internal error occurred and the request could not be completed."
         }

当我使用分区创建此表时 - 一切正常。 当我创建一个27列的小桌子 - 一切正常。 但是当我尝试插入更多列时 - 我得到了这个错误。

这是我的架构和我的代码:

[
  {"name":"timestamp", "type": "timestamp", "mode": "required"},
  {"name":"feid", "type": "string", "mode": "required"},
  {"name":"sid", "type": "string", "mode": "required"},
  {"name":"remote_addr", "type": "string", "mode": "nullable"},
  {"name":"url", "type": "string", "mode": "required"},
  {"name":"url_hostname", "type": "string", "mode": "required"},
  {"name":"url_uri", "type": "string", "mode": "nullable"},
  {"name":"referrer", "type": "string", "mode": "nullable"},
  {"name":"referrer_hostname", "type": "string", "mode": "nullable"},
  {"name":"device_ratio", "type": "string", "mode": "nullable"},
  {"name":"device_screen_size", "type": "string", "mode": "nullable"},
  {"name":"device_window_size", "type": "string", "mode": "nullable"},
  {"name":"timer_start", "type": "integer", "mode": "required"},
  {"name":"timer_init", "type": "integer", "mode": "required"},
  {"name":"user_timezone", "type": "string", "mode": "nullable"},
  {"name":"user_lang", "type": "string", "mode": "nullable"},
  {"name":"nats_code_id", "type": "integer", "mode": "nullable"},
  {"name":"nats_sess", "type": "string", "mode": "nullable"},
  {"name":"ua_os", "type": "string", "mode": "nullable"},
  {"name":"ua_os_version", "type": "string", "mode": "nullable"},
  {"name":"ua_browser", "type": "string", "mode": "nullable"},
  {"name":"ua_browser_version", "type": "string", "mode": "nullable"},
  {"name":"ua_device", "type": "string", "mode": "nullable"},
  {"name":"ua_device_type", "type": "string", "mode": "nullable"},
  {"name":"date_day", "type": "integer", "mode": "nullable"},
  {"name":"date_week", "type": "integer", "mode": "nullable"},
  {"name":"date_month", "type": "integer", "mode": "nullable"},
  {"name":"date_year", "type": "integer", "mode": "nullable"},
  {"name":"geoip_continent", "type": "string", "mode": "nullable"},
  {"name":"geoip_country", "type": "string", "mode": "nullable"},
  {"name":"geoip_region", "type": "string", "mode": "nullable"},
  {"name":"geoip_city", "type": "string", "mode": "nullable"},
  {"name":"geoip_latitude", "type": "string", "mode": "nullable"},
  {"name":"geoip_longitude", "type": "string", "mode": "nullable"},
  {"name":"networkname", "type": "string", "mode": "nullable"},
  {"name":"pagetype", "type": "string", "mode": "nullable"},
  {"name":"pageid", "type": "string", "mode": "nullable"},
  {"name":"templatetype", "type": "string", "mode": "nullable"},
  {"name":"locale", "type": "string", "mode": "nullable"},
  {"name":"zone", "type": "string", "mode": "nullable"}
]

bq mk --schema = pageviews_v3.json --time_partitioning_type = DAY test.pv3

    $rows = [];
    $data = [
    [
     [
      "timestamp" => "2016-09-21 19:57:56",
      "feid" => "safdhiasgih4",
      "sid" => "heghu549023",
      ...
      "zone" => "NONAUTHORIZED",
     ],
     [
      "timestamp" => "2016-09-21 19:44:17",
      "feid" => "agihgu43q92",
      "sid" => "sadfnogsiuphi243",
      ...
      "zone" => "NONAUTHORIZED",
     ]
    ]

];
            foreach ($data as $item) {
                $row = new \Google_Service_Bigquery_TableDataInsertAllRequestRows;
                $row->setJson($item);
                $row->setInsertId(uniqid());
                $rows[] = $row;
            }

    $service = new \Google_Service_Bigquery($this->client);
            $request = new \Google_Service_Bigquery_TableDataInsertAllRequest;
            $request->setKind('bigquery#tableDataInsertAllRequest');
            $request->setRows($rows);

有什么可以反映这个错误?如何获得有关此错误的更多详细信息?

0 个答案:

没有答案