Beispiel #1
0
 function loadFileToBigQuery($uri_array, $schema_array, $dataset, $table_name)
 {
     $loadConfig = new Google_Service_Bigquery_JobConfigurationLoad();
     $loadConfig->setSchema($this->createSchema($schema_array));
     $loadConfig->setSourceUris($uri_array);
     $loadConfig->setDestinationTable($this->createDestinationTable($dataset, $table_name));
     $loadConfig->setCreateDisposition("CREATE_IF_NEEDED");
     $loadConfig->setWriteDisposition("WRITE_APPEND");
     $loadConfig->sourceFormat = 'CSV';
     $config = new Google_Service_Bigquery_JobConfiguration();
     $config->setDryRun(false);
     $config->setLoad($loadConfig);
     $job = new Google_Service_Bigquery_Job();
     $job->setConfiguration($config);
     // this may throw exception: Google_Service_Exception
     $job = $this->service->jobs->insert($this->project_id, $job);
     return $job;
 }