我们只是删除表,创建表,然后使用插入数据,
BigQueryTable table;
try
{
table = dataset.GetTable(tableName);
table.Delete();
}
catch
{
}
finally
{
table = dataset.CreateTable(tableName, schemaBuilder.Build());
}
table.InsertRows(rows);
它有效,但有时会抛出,
Exception while executing function: BigQueryExport Google.Apis.Requests.RequestError
Table xxxx not found. [404]
Errors [
Message[Table xxxx not found.] Location[ - ] Reason[notFound] Domain[global]
]
exception Google.GoogleApiException handled at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw:
at Google.Apis.Requests.ClientServiceRequest`1+<ParseResponse>d__31.MoveNext (Google.Apis, Version=1.49.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Google.Apis.Requests.ClientServiceRequest`1.Execute (Google.Apis, Version=1.49.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab)
at Google.Cloud.BigQuery.V2.BigQueryClientImpl.InsertRows (Google.Cloud.BigQuery.V2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=185c282632e132a0)
我们正在使用google.cloud.bigquery.v2
版本2.1.0
.
由于表创建最终是一致的,因此我在插入行期间添加了重试选项,例如,
var policy = Policy
.Handle<GoogleApiException>()
.WaitAndRetry(new[]
{
TimeSpan.FromMinutes(1),
TimeSpan.FromMinutes(5),
TimeSpan.FromMinutes(10),
TimeSpan.FromMinutes(30),
TimeSpan.FromMinutes(60),
})
.Execute(() => table.InsertRows(rows));
还有一些其他方法可以解决此问题,如此处所述https://github.com/googleapis/google-cloud-dotnet/issues/8146 https://github.com/googleapis/google-cloud-dotnet/issues/8146
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)