Skip to content
Snippets Groups Projects
Commit 17b8327c authored by Karin Pettersen's avatar Karin Pettersen
Browse files

Created getBuilder

parent af92e084
Branches
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@ import com.google.cloud.bigquery.Job;
import com.google.cloud.bigquery.JobInfo;
import com.google.cloud.bigquery.QueryJobConfiguration;
import com.google.cloud.bigquery.TableResult;
import com.sun.media.jfxmedia.AudioClip;
import java.io.File;
import java.io.FileInputStream;
......@@ -28,16 +29,20 @@ public class DB {
return credentials;
}
public static void getFromExistingTable() throws Exception {
// Step 1: Initialize BigQuery service
// Here we set our project ID and get the `BigQuery` service object
// this is the interface to our BigQuery instance that
// we use to execute jobs on
// Step 1: Initialize BigQuery service
// Here we set our project ID and get the `BigQuery` service object
// this is the interface to our BigQuery instance that
// we use to execute jobs on
private static BigQuery getBuilder() throws Exception {
BigQuery bigquery = BigQueryOptions.newBuilder().
setCredentials(getCredentials()).
setProjectId("sf-drying-optimization")
.build().getService();
return bigquery;
}
public static void getFromExistingTable() throws Exception {
// Step 2: Prepare query job
// A "QueryJob" is a type of job that executes SQL queries
......@@ -50,7 +55,8 @@ public class DB {
// Step 3: Run the job on BigQuery
// create a `Job` instance from the job configuration using the BigQuery service
// the job starts executing once the `create` method executes
Job queryJob = bigquery.create(JobInfo.newBuilder(queryConfig).build());
Job queryJob = getBuilder().create(JobInfo.newBuilder(queryConfig).build());
queryJob = queryJob.waitFor();
// the waitFor method blocks until the job completes
// and returns `null` if the job doesn't exist anymore
......
package com.application.DB;
public class Sort {
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment