0
votes

From Google Cloud Console, we could manually create external bigquery table which will link to Google cloud storage Json new line delimited file.

But in bigquery php client library, https://cloud.google.com/bigquery/docs/tables, I could not find sample code let me to create bigquery external table linking to cloud storage saved json file.

function create_table($projectId, $datasetId, $tableId, $schema)
{
  $bigQuery = new BigQueryClient([
    'projectId' => $projectId,
  ]);
  $dataset = $bigQuery->dataset($datasetId);
  $options = ['schema' => $schema];
  $table = $dataset->createTable($tableId, $options);
  return $table;
}

Does that mean "create external bigquery table" is not available through bigquery client library?

Thanks!

1

1 Answers

1
votes

It is available through the client library. In the example snippet, you provided, the 'schema' is being specified as an 'option'. The external table definition is another option you can specify. Here is the underlying Table resource: https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#resource

The externalDataConfiguration part is what you need to specify to create a external (aka Federated) BigQuery table.