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(); }
public async Task GetQueryResults_NonQuery() { var resource = new Job { JobReference = new JobReference { ProjectId = "project", JobId = "job" }, Configuration = new JobConfiguration { Copy = new JobConfigurationTableCopy { } } }; var job = new BigQueryJob(new SimpleClient(), resource); Assert.Throws <InvalidOperationException>(() => job.GetQueryResults()); await Assert.ThrowsAsync <InvalidOperationException>(() => job.GetQueryResultsAsync()); }
public async Task GetQueryResults_NoJobReference() { var resource = new Job { Configuration = new JobConfiguration { DryRun = true, Query = new JobConfigurationQuery { DestinationTable = new TableReference { ProjectId = "project", DatasetId = "dataset", TableId = "table" } } } }; var job = new BigQueryJob(new SimpleClient(), resource); Assert.Throws <InvalidOperationException>(() => job.GetQueryResults()); await Assert.ThrowsAsync <InvalidOperationException>(() => job.GetQueryResultsAsync()); }