我无法将数据推送到大查询

时间:2015-12-11 10:26:24

标签: google-bigquery

我得到 insertAll:(503)从大查询执行时遇到错误。

我使用 BigQuery Browser Tool 创建了表格。我给了空的csv文件。我正在使用服务帐户的p12文件进行身份验证。我可以获得访问令牌。但无论我做什么我都无法推送任何新数据。这是我的代码

$g_service_private_key = File::get(storage_path().'/aa-aa.p12');
$scopes = array('https://www.googleapis.com/auth/bigquery', 'https://www.googleapis.com/auth/bigquery.insertdata');
$credentials = new Google_Auth_AssertionCredentials(
    $bq_client_email,
    $scopes,
    $g_service_private_key
);
$client = new Google_Client();
$client->setAssertionCredentials($credentials);
if ($client->getAuth()->isAccessTokenExpired()) {
    $client->getAuth()->refreshTokenWithAssertion();
}
$client->getAccessToken();
$service = new Google_Service_Bigquery($client);

$arr = array(
    'title' => 'why not working',
    'status' => 'working',
);
$service = new Google_Service_Bigquery($client);
$payload = json_decode(json_encode($arr));

$rows = array();
$row = new Google_Service_Bigquery_TableDataInsertAllRequestRows();
$row->setJson($payload);
$row->setInsertId(time());
$rows[0] = $row;
print_r($rows);
//Stream the event into BQ
$request = new Google_Service_Bigquery_TableDataInsertAllRequest();
$request->setKind('bigquery#tableDataInsertAllRequest');
$request->setRows($rows);
try {
    $response = $service->tabledata->insertAll($bq_project_id, 'aaa', $bq_table, $request); //fire the insert reques
} catch (Exception $e) {
    echo $e->getMessage();
}

0 个答案:

没有答案