Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用C语言的大查询插件#_C#_Google Bigquery - Fatal编程技术网

C# 使用C语言的大查询插件#

C# 使用C语言的大查询插件#,c#,google-bigquery,C#,Google Bigquery,我在尝试使用大查询插入数据时使用了这段代码。 一切正常,但我的桌子是空的。 我的代码有什么问题 string SERVICE_ACCOUNT_EMAIL = "MyAccount"; var certificate = new X509Certificate2(@"XXX.p12", "notasecret", X509KeyStorageFlags.Exportable); ServiceAccountCredential credential

我在尝试使用大查询插入数据时使用了这段代码。 一切正常,但我的桌子是空的。 我的代码有什么问题

         string SERVICE_ACCOUNT_EMAIL = "MyAccount";
        var certificate = new X509Certificate2(@"XXX.p12", "notasecret", X509KeyStorageFlags.Exportable);
        ServiceAccountCredential credential = new ServiceAccountCredential(
          new ServiceAccountCredential.Initializer(SERVICE_ACCOUNT_EMAIL)
          {
              Scopes = new[] { BigqueryService.Scope.BigqueryInsertdata, BigqueryService.Scope.Bigquery }

          }.FromCertificate(certificate));
        // Create the service.
        var service = new BigqueryService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = "test"

        });

        Google.Apis.Bigquery.v2.Data.TableDataInsertAllRequest tabreq = new Google.Apis.Bigquery.v2.Data.TableDataInsertAllRequest();
        List<Google.Apis.Bigquery.v2.Data.TableDataInsertAllRequest.RowsData> tabrows = new List<Google.Apis.Bigquery.v2.Data.TableDataInsertAllRequest.RowsData>();
        Google.Apis.Bigquery.v2.Data.TableDataInsertAllRequest.RowsData rd = new Google.Apis.Bigquery.v2.Data.TableDataInsertAllRequest.RowsData();
        IDictionary<string, object> r = new Dictionary<string, object>();
        r.Add("Key", "Value");
        rd.Json = r;
        tabrows.Add(rd);
        tabreq.Rows = tabrows;
        tabreq.Kind = "bigquery#tableDataInsertAllRequest";
        service.Tabledata.InsertAll(tabreq, "xxx", "xxx", "xxx"); 
string SERVICE\u ACCOUNT\u EMAIL=“MyAccount”;
var证书=新的X509Certificate2(@“XXX.p12”,“notasecret”,X509keystrageFlags.Exportable);
ServiceAccountCredential credential=新ServiceAccountCredential(
新ServiceAccountCredential.初始值设定项(服务帐户电子邮件)
{
Scopes=new[]{BigqueryService.Scope.BigqueryInsertdata,BigqueryService.Scope.Bigquery}
}.FromCertificate(证书));
//创建服务。
var service=new BigqueryService(new BaseClientService.Initializer()
{
HttpClientInitializer=凭证,
ApplicationName=“测试”
});
Google.api.Bigquery.v2.Data.TableDataInsertAllRequest tabreq=new Google.api.Bigquery.v2.Data.TableDataInsertAllRequest();
列表选项卡行=新列表();
Google.api.Bigquery.v2.Data.TableDataInsertAllRequest.RowsData rd=新的Google.api.Bigquery.v2.Data.TableDataInsertAllRequest.RowsData();
IDictionary r=新字典();
r、 添加(“关键”、“价值”);
rd.Json=r;
tabrows.Add(rd);
tabreq.Rows=tabrows;
tabreq.Kind=“bigquery#tableDataInsertAllRequest”;
service.Tabledata.InsertAll(tabreq,“xxx”、“xxx”、“xxx”);

您的代码看起来不错,但唯一的问题是您需要发送数据,实际上您没有发送任何数据,请测试此代码并通知我(我创建了一个包含两个字段P1和P2的表)

var logs=newlist();
var theLog=new TableDataInsertAllRequest.RowsData();
Json=newdictionary();
Add(“P1”,“Hola”);
Add(“P2”,“Mundo”);
添加(日志);
var service=GetBigQueryService();
var content=new TableDataInsertAllRequest();
content.Rows=日志;
content.Kind=“bigquery#tableDataInsertAllRequest”;
content.IgnoreUnknownValues=true;
content.SkipInvalidRows=true;
var insertTask=service.Tabledata.InsertAll(内容,“您的\u项目\u Id”、“您的\u数据集”、“您的\u表”);
TableDataInsertAllResponse=insertTask.Execute();

我不确定BigQuery是如何工作的,但您是在刷新数据还是调用某种形式的提交函数?@RichardBarker否。我认为Big Query没有任何提交语句。请尝试将“跳过表上的无效行”设置为true?您在TableDataInsertResponse对象的InsertErrors属性中没有得到任何您应该得到的东西?更重要的是,你是如何告诉谷歌哪些表格要插入行的?我在代码中看不到任何与表名相关的内容。我肯定您知道它——但如果您不知道,对于其他人来说——这里是api参考链接:另外,您如何检查表中是否存在行?通过tabledata.insertAll插入的行不能通过某些操作(例如,表复制或表导出)立即可见。
var logs = new List<TableDataInsertAllRequest.RowsData>();
var theLog = new TableDataInsertAllRequest.RowsData();
theLog.Json = new Dictionary<string, object>();
theLog.Json.Add("P1", "Hola");
theLog.Json.Add("P2", "Mundo");            
logs.Add(theLog);

var service = GetBigQueryService();
var content = new TableDataInsertAllRequest();
content.Rows = logs;
content.Kind = "bigquery#tableDataInsertAllRequest";
content.IgnoreUnknownValues = true;
content.SkipInvalidRows = true;

var insertTask = service.Tabledata.InsertAll(content, "Your_Project_Id", "Your_DataSet", "Your_Table");
TableDataInsertAllResponse response = insertTask.Execute();