0

I've searched StackOverflow and on the web and haven't found any code samples for using the Google BigQuery C# API library

Within Visual Studio, I was successfully able to add the BigQuery NuGet Library:

PM> Install-Package Google.Apis.Bigquery.v2 -Pre 

I have C# code to authenticate to the Google project ID using OAuth 2.0, and that is working. But it is not clear on how to proceed with the BigQuery API. My goal is to insert data into a BigQuery table.

3
  • 1
    Your question seems a bit premature. If you start here and begin clicking through the links provided on each page, you will eventually find things like this. There are insert methods in those subclasses. Commented Jan 9, 2014 at 18:49
  • Well, @RobertHarvey, I posted the link to the API documentation in my question, so its not a problem of knowing where to find the library documentation. But I can't find any actual SAMPLE CODE, which is what is most helpful to someone like me who is brand new to this API. Commented Jan 9, 2014 at 22:38
  • Currently we don't have a working sample for this API, but there are several samples for other APIs in our samples repository - code.google.com/p/google-api-dotnet-client/source/…. Commented Jan 15, 2014 at 23:06

1 Answer 1

3

I was looking around for the same thing. Eventually, i made it work thanks to bunch of posts i came across. I wish I could mention links here but i lost track of it since it was quite a while ago. This code does streaming insert data into BigQuery table using C#.

protected void DoStreamingInsert() { var rowList = new List<TableDataInsertAllRequest.RowsData>(); var row1 = new TableDataInsertAllRequest.RowsData(); var row2 = new TableDataInsertAllRequest.RowsData(); row1.Json = new Dictionary<string, object>(); row1.Json.Add("TextField", "SomeTest"); row1.Json.Add("DataField", "2014-10-31 00:00:00.0000"); //row1.InsertId = DateTime.Now.Ticks.ToString(); Give this ID to prevent duplicate insert row2.Json = new Dictionary<string, object>(); row2.Json.Add("TextField", "SomeTest1"); row2.Json.Add("DataField", "2014-11-30 00:00:00.0000"); rowList.Add(row1); rowList.Add(row2); var content = new TableDataInsertAllRequest(); content.Rows = rowList; content.Kind = "bigquery#tableDataInsertAllRequest"; content.IgnoreUnknownValues = true; content.SkipInvalidRows = true; var insertTask = BQDefs.BQService.Tabledata.InsertAll(content, BQDefs.ProjectID, BQDefs.DataSet, BQDefs.TableName); TableDataInsertAllResponse response = insertTask.Execute(); }

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.