Google BigQuery PHP从URL加载数据


Google BigQuery PHP Load Data from URL

我正在连接到API,并获得TSV格式的报告。我需要将报告上传到Google BigQuery,但到目前为止,我找到的所有文档都加载了谷歌云存储的数据。有没有办法从一个单独的URL加载数据?

这是我迄今为止的代码:

$service = new Google_BigqueryService($client);
// Your project number, from the developers.google.com/console project you created
// when signing up for BigQuery
$project_number = '*******';
// Information about the destination table
$destination_table = new Google_TableReference();
$destination_table->setProjectId($project_number);
$destination_table->setDatasetId('php_test');
$destination_table->setTableId('my_new_table');
// Information about the schema for your new table
$schema_fields = array();
$schema_fields[0] = new Google_TableFieldSchema();
$schema_fields[0]->setName('Date');
$schema_fields[0]->setType('string');
$schema_fields[1] = new Google_TableFieldSchema();
$schema_fields[1]->setName('PartnerId');
$schema_fields[1]->setType('string');
....
$destination_table_schema = new Google_TableSchema();
$destination_table_schema->setFields($schema_fields);
// Set the load configuration, including source file(s) and schema
$load_configuration = new Google_JobConfigurationLoad();
$load_configuration->setSourceUris(array('EXTERNAL URL WITH TSV'));
$load_configuration->setDestinationTable($destination_table);
$load_configuration->setSchema($destination_table_schema);

$job_configuration = new Google_JobConfiguration();
$job_configuration->setLoad($load_configuration);
$load_job = new Google_Job();
$load_job->setKind('load');        
$load_job->setConfiguration($job_configuration);
$jobs = $service->jobs;
$response = $jobs->insert($project_number, $load_job);

我意识到这是针对谷歌云存储的,但我不想使用它,如果我只是想通过它传递数据并在一小时内删除它。

有没有PHP代码可以让我使用外部URL并从中加载数据?

正如上面提到的Pentiuum10,BigQuery不支持从非谷歌云存储URL读取。所涉及的物流将是棘手的。。。我们需要凭据来访问数据,而我们并不想对此负责。如果这是一个流行的请求,我们可能最终支持不受限制或支持oauth2的外部路径。也就是说,到目前为止,我们还没有很多用户要求这样做。

请随时通过此处的公共问题跟踪器提交功能请求:https://code.google.com/p/google-bigquery/issues/.