谷歌api-如何选择大型数据集并使用c应用程序从bigquery加载数据表



我已经创建了C#.NET应用程序(使用服务身份验证)。

我正在尝试运行select语句(来自Google BigQuery的Public Sample Table)并将结果加载到数据表中,但无法实现,它将错误作为抛出

导致错误的查询是:"SELECT*FROM[publicdata:samples.github_timeline]"

Google.Apis.Requests.RequestError
Response too large to return. Consider setting allowLargeResults to true in your job configuration. For more information, see https://cloud.google.com/bigquery/troubleshooting-errors [403]
Errors [
Message[Response too large to return. Consider setting allowLargeResults to true in your job configuration. For more information, see https://cloud.google.com/bigquery/troubleshooting-errors] Location[ - ] Reason[responseTooLarge] Domain[global]
].

这是C#代码。

        String serviceAccountEmail = "SERVICE ACCOUNT EMAIL ADDRESS";
            var certificate = new X509Certificate2(@"KEY FILE NAME", "KEY SECRET", X509KeyStorageFlags.Exportable);
            ServiceAccountCredential credential = new ServiceAccountCredential(
               new ServiceAccountCredential.Initializer(serviceAccountEmail)
               {
                   Scopes = new[] { BigqueryService.Scope.Bigquery, BigqueryService.Scope.BigqueryInsertdata, BigqueryService.Scope.CloudPlatform, BigqueryService.Scope.DevstorageFullControl }
               }.FromCertificate(certificate));
            BigqueryService Service = new BigqueryService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "PROJECT NAME"
            });
            string query = "SELECT * FROM [publicdata:samples.github_timeline]";
            JobsResource j = Service.Jobs;
            QueryRequest qr = new QueryRequest();
            string ProjectID = "PROJECT ID";
            qr.Query = query;
            qr.MaxResults = Int32.MaxValue;
            qr.TimeoutMs = Int32.MaxValue;
            DataTable DT = new DataTable();
            int i = 0;
            QueryResponse response = j.Query(qr, ProjectID).Execute();

我们如何选择大型数据集并以最佳方式将结果加载到Datatable中?担心BigQuery会引发这些类型的错误,然后我们将如何信任我们的程序100%工作。

返回大型查询结果

通常,查询具有最大响应大小。如果您计划运行如果查询可能返回较大的结果,则可以设置allowLargeResults在您的工作配置中设置为true。

即使在结果集很小,并且受到其他限制:

必须指定目标表。不能指定顶级ORDER BY、TOP或LIMIT子句。这样做会否定使用allowLargeResults,因为无法再计算查询输出并行。只有在以下情况下,窗口函数才能返回大型查询结果与PARTITION BY子句一起使用。

问题是Google.net客户端库是否支持在请求中添加allowLargeResults。检查选项值。

如果你幸运的话,比如:

qr.allowLargeResults=真实

相关内容

  • 没有找到相关文章

最新更新