private void checkNotDryRun(String op) { checkNotDryRun(getConfiguration(), op); }
/** * Sends a job cancel request. * * <p>Example of cancelling a job. * * <pre>{@code * if (job.cancel()) { * return true; // job successfully cancelled * } else { * // job not found * } * }</pre> * * @return {@code true} if cancel request was sent successfully, {@code false} if job was not * found * @throws BigQueryException upon failure */ public boolean cancel() { checkNotDryRun("cancel"); return bigquery.cancel(getJobId()); }
@Override public TableResult query(QueryJobConfiguration configuration, JobOption... options) throws InterruptedException, JobException { Job.checkNotDryRun(configuration, "query"); return create(JobInfo.of(configuration), options).getQueryResults(); }
@Override public TableResult query(QueryJobConfiguration configuration, JobId jobId, JobOption... options) throws InterruptedException, JobException { Job.checkNotDryRun(configuration, "query"); return create(JobInfo.of(jobId, configuration), options).getQueryResults(); }
/** * Fetches current job's latest information. Returns {@code null} if the job does not exist. * * <p>Example of reloading all fields until job status is DONE. * * <pre>{@code * while (!JobStatus.State.DONE.equals(job.getStatus().getState())) { * Thread.sleep(1000L); * job = job.reload(); * } * }</pre> * * <p>Example of reloading status field until job status is DONE. * * <pre>{@code * while (!JobStatus.State.DONE.equals(job.getStatus().getState())) { * Thread.sleep(1000L); * job = job.reload(BigQuery.JobOption.fields(BigQuery.JobField.STATUS)); * } * }</pre> * * @param options job options * @return a {@code Job} object with latest information or {@code null} if not found * @throws BigQueryException upon failure */ public Job reload(JobOption... options) { checkNotDryRun("reload"); return bigquery.getJob(getJobId(), options); }
/** * Checks if this job exists. * * <p>Example of checking that a job exists. * * <pre>{@code * if (!job.exists()) { * // job doesn't exist * } * }</pre> * * @return {@code true} if this job exists, {@code false} otherwise * @throws BigQueryException upon failure */ public boolean exists() { checkNotDryRun("exists"); return bigquery.getJob(getJobId(), JobOption.fields()) != null; }
/** * Checks if this job has completed its execution, either failing or succeeding. If the job does * not exist this method returns {@code true}. * * <p>Example of waiting for a job until it reports that it is done. * * <pre>{@code * while (!job.isDone()) { * Thread.sleep(1000L); * } * }</pre> * * @return {@code true} if this job is in {@link JobStatus.State#DONE} state or if it does not * exist, {@code false} if the state is not {@link JobStatus.State#DONE} * @throws BigQueryException upon failure */ public boolean isDone() { checkNotDryRun("isDone"); Job job = bigquery.getJob(getJobId(), JobOption.fields(BigQuery.JobField.STATUS)); return job == null || JobStatus.State.DONE.equals(job.getStatus().getState()); } /**
checkNotDryRun("getQueryResults"); if (getConfiguration().getType() != Type.QUERY) { throw new UnsupportedOperationException(
checkNotDryRun("waitFor"); Object completedJobResponse; if (getConfiguration().getType() == Type.QUERY) {
private void checkNotDryRun(String op) { checkNotDryRun(getConfiguration(), op); }
/** * Sends a job cancel request. * * <p>Example of cancelling a job. * * <pre>{@code * if (job.cancel()) { * return true; // job successfully cancelled * } else { * // job not found * } * }</pre> * * @return {@code true} if cancel request was sent successfully, {@code false} if job was not * found * @throws BigQueryException upon failure */ public boolean cancel() { checkNotDryRun("cancel"); return bigquery.cancel(getJobId()); }
/** * Fetches current job's latest information. Returns {@code null} if the job does not exist. * * <p>Example of reloading all fields until job status is DONE. * * <pre>{@code * while (!JobStatus.State.DONE.equals(job.getStatus().getState())) { * Thread.sleep(1000L); * job = job.reload(); * } * }</pre> * * <p>Example of reloading status field until job status is DONE. * * <pre>{@code * while (!JobStatus.State.DONE.equals(job.getStatus().getState())) { * Thread.sleep(1000L); * job = job.reload(BigQuery.JobOption.fields(BigQuery.JobField.STATUS)); * } * }</pre> * * @param options job options * @return a {@code Job} object with latest information or {@code null} if not found * @throws BigQueryException upon failure */ public Job reload(JobOption... options) { checkNotDryRun("reload"); return bigquery.getJob(getJobId(), options); }
@Override public TableResult query(QueryJobConfiguration configuration, JobId jobId, JobOption... options) throws InterruptedException, JobException { Job.checkNotDryRun(configuration, "query"); return create(JobInfo.of(jobId, configuration), options).getQueryResults(); }
@Override public TableResult query(QueryJobConfiguration configuration, JobOption... options) throws InterruptedException, JobException { Job.checkNotDryRun(configuration, "query"); return create(JobInfo.of(configuration), options).getQueryResults(); }
/** * Checks if this job exists. * * <p>Example of checking that a job exists. * * <pre>{@code * if (!job.exists()) { * // job doesn't exist * } * }</pre> * * @return {@code true} if this job exists, {@code false} otherwise * @throws BigQueryException upon failure */ public boolean exists() { checkNotDryRun("exists"); return bigquery.getJob(getJobId(), JobOption.fields()) != null; }
/** * Checks if this job has completed its execution, either failing or succeeding. If the job does * not exist this method returns {@code true}. * * <p>Example of waiting for a job until it reports that it is done. * * <pre>{@code * while (!job.isDone()) { * Thread.sleep(1000L); * } * }</pre> * * @return {@code true} if this job is in {@link JobStatus.State#DONE} state or if it does not * exist, {@code false} if the state is not {@link JobStatus.State#DONE} * @throws BigQueryException upon failure */ public boolean isDone() { checkNotDryRun("isDone"); Job job = bigquery.getJob(getJobId(), JobOption.fields(BigQuery.JobField.STATUS)); return job == null || JobStatus.State.DONE.equals(job.getStatus().getState()); } /**
checkNotDryRun("getQueryResults"); if (getConfiguration().getType() != Type.QUERY) { throw new UnsupportedOperationException(
checkNotDryRun("waitFor"); Object completedJobResponse; if (getConfiguration().getType() == Type.QUERY) {