Executing a query and displaying the result

The following code will execute a query job and display the results in the console. The output will be the schema of the rows returned for the query and the individual column values for each row:

BigQuery provides an option to get the cost estimate for running a query without actually running it. To do this, use the QueryOptions.DryRun flag and set it to true. This feature can be used to run queries in test mode to estimate the cost of a query. If the query is going to return more than 128 MB of compressed data as a result, then set the QueryOptions.AllowLargeResults flag to true.

Set QueryOptions.UseQueryCache to true to retrieve the results of the query from the BigQuery cache. By default, all queries executed in BigQuery from a Google Account are cached for 24 hours if the table used in the query is not changed. When the results are retrieved from the query cache, it is not billed to the user.

Call the preceding method from the main method as shown next and verify the output in the console. Load the rows into your application objects before passing it to other layers of your application:

The data access layer in the application should make API calls to BigQuery and convert the results returned to classes for the other layers of the application to use as objects instead of raw JSON data.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.173.53