Insert insert = bigquery.jobs().insert(exporterConfig.getBigqueryProjectId(), job); JobReference jr = insert.execute().getJobReference(); log.warning("Uri: " + gsUrl + ", JobId: " + jr.getJobId());
/** * Creates a Query Job for a particular query on a dataset * * @param bigquery an authorized BigQuery client * @param projectId a String containing the project ID * @param querySql the actual query string * @return a reference to the inserted query job * @throws IOException */ public static JobReference startQuery(Bigquery bigquery, String projectId, String querySql) throws IOException { System.out.format("\nInserting Query Job: %s\n", querySql); Job job = new Job(); JobConfiguration config = new JobConfiguration(); JobConfigurationQuery queryConfig = new JobConfigurationQuery(); config.setQuery(queryConfig); job.setConfiguration(config); queryConfig.setQuery(querySql); Insert insert = bigquery.jobs().insert(projectId, job); insert.setProjectId(projectId); JobReference jobId = insert.execute().getJobReference(); System.out.format("\nJob ID of Query Job is: %s\n", jobId.getJobId()); return jobId; }
Job insertedJob = bqClient.jobs().insert(projectId, job).execute();
do { try { client.jobs().insert(jobRef.getProjectId(), job).execute(); LOG.info( "Started BigQuery job: {}.\n{}",
Job response = null; try { response = insert.execute(); logger.atFine().log("Successfully inserted job '%s'. Response: '%s'", job, response); } catch (IOException ioe) {
/** * Starts a new asynchronous job. Requires the Can View project role. * * Create a request for the method "jobs.insert". * * This request holds the parameters needed by the the bigquery server. After setting any * optional parameters, call the {@link Insert#execute()} method to invoke the remote operation. * <p> {@link * Insert#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)} must * be called to initialize this instance immediately after invoking the constructor. </p> * * <p> * This constructor should be used for uploading media content. * </p> * * @param projectId Project ID of the project that will be billed for the job * @param content the {@link com.google.api.services.bigquery.model.Job} media metadata or {@code null} if none * @param mediaContent The media HTTP content or {@code null} if none. * @since 1.13 */ protected Insert(java.lang.String projectId, com.google.api.services.bigquery.model.Job content, com.google.api.client.http.AbstractInputStreamContent mediaContent) { super(Bigquery.this, "POST", "/upload/" + getServicePath() + REST_PATH, content, com.google.api.services.bigquery.model.Job.class); this.projectId = com.google.api.client.util.Preconditions.checkNotNull(projectId, "Required parameter projectId must be specified."); initializeMediaUpload(mediaContent); }
/** * Starts a new asynchronous job. Requires the Can View project role. * * Create a request for the method "jobs.insert". * * This request holds the parameters needed by the the bigquery server. After setting any optional * parameters, call the {@link Insert#execute()} method to invoke the remote operation. * * <p> * This method should be used for uploading media content. * </p> * * @param projectId Project ID of the project that will be billed for the job * @param content the {@link com.google.api.services.bigquery.model.Job} media metadata or {@code null} if none * @param mediaContent The media HTTP content or {@code null} if none. * @return the request * @throws java.io.IOException if the initialization of the request fails */ public Insert insert(java.lang.String projectId, com.google.api.services.bigquery.model.Job content, com.google.api.client.http.AbstractInputStreamContent mediaContent) throws java.io.IOException { Insert result = new Insert(projectId, content, mediaContent); initialize(result); return result; }
/** * Starts a new asynchronous job. Requires the Can View project role. * * Create a request for the method "jobs.insert". * * This request holds the parameters needed by the bigquery server. After setting any optional * parameters, call the {@link Insert#execute()} method to invoke the remote operation. * * @param projectId Project ID of the project that will be billed for the job * @param content the {@link com.google.api.services.bigquery.model.Job} * @return the request */ public Insert insert(java.lang.String projectId, com.google.api.services.bigquery.model.Job content) throws java.io.IOException { Insert result = new Insert(projectId, content); initialize(result); return result; }
@Override public Job create(Job job, Map<Option, ?> options) { try { String projectId = job.getJobReference() != null ? job.getJobReference().getProjectId() : this.options.getProjectId(); return bigquery .jobs() .insert(projectId, job) .setFields(Option.FIELDS.getString(options)) .execute(); } catch (IOException ex) { throw translate(ex); } }
void submitJob(String projectId, Job job) throws IOException { client.jobs() .insert(projectId, job) .execute(); }
Job content = new Job(); JobConfiguration cfg = new JobConfiguration(); JobConfigurationQuery jobConfigurationQuery = new JobConfigurationQuery(); UserDefinedFunctionResource userDefinedFunctionResource = new UserDefinedFunctionResource(); userDefinedFunctionResource.setResourceUri("gs://mybucket/udf.js"); jobConfigurationQuery.setUserDefinedFunctionResources(Lists.newArrayList( userDefinedFunctionResource )); cfg.setQuery(jobConfigurationQuery); content.setConfiguration(cfg); Bigquery.Jobs.Insert request = bigqueryService.jobs().insert(projectId, content); Job response = request.execute();
@Override public Job create(Job job, Map<Option, ?> options) { try { String projectId = job.getJobReference() != null ? job.getJobReference().getProjectId() : this.options.getProjectId(); return bigquery .jobs() .insert(projectId, job) .setFields(Option.FIELDS.getString(options)) .execute(); } catch (IOException ex) { throw translate(ex); } }