I have a working .netcore console app written in C# that can run pretty much every example shown here: Google .Net client library
For example, this code runs perfectly fine:
BigQueryClient client = BigQueryClient.Create(projectId);
string sql = "SELECT * FROM projectid.datasetname.tablename";
BigQueryParameter[] parameters = null;
BigQueryResults results = client.ExecuteQuery(sql, parameters);
foreach (BigQueryRow row in results)
{
Console.WriteLine($"{row["colname1"]}: {row["colname2"]}");
}
However, if I try to run a federated query as shown below, the API complains about the single quote right after "EXTERNAL_QUERY(". This code does not work:
BigQueryClient client = BigQueryClient.Create(projectId);
string sql = "SELECT * FROM EXTERNAL_QUERY('connection-id', 'SELECT * FROM schema.tablename;');";
BigQueryParameter[] parameters = null;
BigQueryResults results = client.ExecuteQuery(sql, parameters);
foreach (BigQueryRow row in results)
{
Console.WriteLine($"{row["colname1"]}: {row["colname2"]}");
}
I've tried using escaped double quotes as well.
Does anyone know how to send this type of request?
Google's documentation includes examples which you can view here: Google API .Net Client Library
However, the documentation does not cover how to run federated queries, so I'm stumped.
A few clarification points for anyone else who needs them:
- I am using a real connection id; I've replaced the real information with placeholders in the example code I provided.
- I have no trouble running the federated query exactly as I've shown it here (with triplets, or double quotes) inside BigQuery. That tells me there's nothing wrong with the query syntax itself
- The problem only occurs when I try running the exact same federated query inside my c# app. The specific exception I get is:
Google.GoogleApiException (The service bigquery has thrown an exception. HttpStatusCode is BadRequest. Encountered "" at line 1, column 30.)
--- You can see it's basically complaining about the single, double, or tipple quotation mark right before the connection-id.