public void CopyTable( string projectId = "your-project-id", string destinationDatasetId = "your_dataset_id" ) { BigQueryClient client = BigQueryClient.Create(projectId); TableReference sourceTableRef = new TableReference() { TableId = "shakespeare", DatasetId = "samples", ProjectId = "bigquery-public-data" }; TableReference destinationTableRef = client.GetTableReference( destinationDatasetId, "destination_table"); BigQueryJob job = client.CreateCopyJob( sourceTableRef, destinationTableRef) .PollUntilCompleted() // Wait for the job to complete. .ThrowOnAnyError(); // Retrieve destination table BigQueryTable destinationTable = client.GetTable(destinationTableRef); Console.WriteLine( $"Copied {destinationTable.Resource.NumRows} rows from table " + $"{sourceTableRef.DatasetId}.{sourceTableRef.TableId} " + $"to {destinationTable.FullyQualifiedId}." ); }
public void PopulateTable( string query, string datasetId, string newTableId, BigQueryClient client) { var destination = client.GetTableReference(datasetId, newTableId); BigQueryJob job = client.CreateQueryJob(query, new QueryOptions { DestinationTable = destination }); // Wait for the job to complete. job.GetQueryResults(); }
// [START copy_table] public void CopyTable( string datasetId, string tableIdToBeCopied, string newTableId, BigQueryClient client) { var table = client.GetTable(datasetId, tableIdToBeCopied); string query = $"SELECT * FROM {table}"; var destination = client.GetTableReference(datasetId, newTableId); BigQueryJob job = client.CreateQueryJob(query, new QueryOptions { DestinationTable = destination }); // Wait for the job to complete. job.GetQueryResults(); }
// [START copy_table] public void CopyTable( string datasetId, string tableIdToBeCopied, string newTableId, BigQueryClient client) { var table = client.GetTable(datasetId, tableIdToBeCopied); string query = $"SELECT * FROM {table}"; var destination = client.GetTableReference(datasetId, newTableId); BigQueryJob job = client.CreateQueryJob(query, new CreateQueryJobOptions { DestinationTable = destination }); // Wait for the job to complete. job.PollQueryUntilCompleted(); }
public void PopulateTable( string query, string datasetId, string newTableId, BigQueryClient client) { var destination = client.GetTableReference(datasetId, newTableId); BigQueryJob job = client.CreateQueryJob(query, new CreateQueryJobOptions { DestinationTable = destination }); // Wait for the job to complete. job.PollQueryUntilCompleted(); }