diff --git a/csharp/src/Drivers/BigQuery/BigQueryStatement.cs b/csharp/src/Drivers/BigQuery/BigQueryStatement.cs index 797068213a..356260c97f 100644 --- a/csharp/src/Drivers/BigQuery/BigQueryStatement.cs +++ b/csharp/src/Drivers/BigQuery/BigQueryStatement.cs @@ -93,27 +93,8 @@ private async Task ExecuteQueryInternalAsync() getQueryResultsOptions.Timeout = TimeSpan.FromSeconds(seconds); } - Func> checkJobStatus = async () => - { - while (true) - { - var jobWithStatus = await Client.GetJobAsync(jobReference); - - if (jobWithStatus.State == JobState.Done) - { - if (jobWithStatus.Status.ErrorResult != null) - { - // TODO: log - Debug.WriteLine($"Error: {jobWithStatus.Status.ErrorResult.Message}"); - } - - return jobWithStatus; - } - } - }; - - await ExecuteWithRetriesAsync(checkJobStatus); - + // We can't checkJobStatus, Otherwise, the timeout in QueryResultsOptions is meaningless. + // When encountering a long-running job, it should be controlled by the timeout in the Google SDK instead of blocking in a while loop. Func> getJobResults = async () => { // if the authentication token was reset, then we need a new job with the latest token @@ -224,7 +205,6 @@ public override UpdateResult ExecuteUpdate() private async Task ExecuteUpdateInternalAsync() { - QueryOptions options = ValidateOptions(); GetQueryResultsOptions getQueryResultsOptions = new GetQueryResultsOptions(); if (Options?.TryGetValue(BigQueryParameters.GetQueryResultsOptionsTimeout, out string? timeoutSeconds) == true && @@ -234,7 +214,8 @@ private async Task ExecuteUpdateInternalAsync() getQueryResultsOptions.Timeout = TimeSpan.FromSeconds(seconds); } - Func> func = () => Client.ExecuteQueryAsync(SqlQuery, null, options, getQueryResultsOptions); + // Cannot set destination table in jobs with DDL statements, otherwise an error will be prompted + Func> func = () => Client.ExecuteQueryAsync(SqlQuery, null, null, getQueryResultsOptions); BigQueryResults? result = await ExecuteWithRetriesAsync(func); long updatedRows = result?.NumDmlAffectedRows.HasValue == true ? result.NumDmlAffectedRows.Value : -1L;