Database Reference
In-Depth Information
Finally, WRITE_TRUNCATE will atomically replace the data that is currently
in the table with the results of this job. This can be useful, for example,
to reload data in a table. An analogy to WRITE_TRUNCATE is the scene
in the first Indiana Jones movie where he takes the golden idol from the
temple—as he takes it, he replaces it with a bag of sand that seems to be
about the same size as the idol. Hopefully, your usage of WRITE_TRUNCATE
will have a better outcome than in the movie.
The bq tool does not give control over write dispositions directly. By default,
for example, load jobs run as WRITE_APPEND . It does however allow you
to change the disposition to WRITE_TRUNCATE by passing the --replace
flag:
$ echo a,b,c > temp.csv
$ bq load --replace scratch.table1 temp.csv "f1,f2,f3"
Waiting on bqjob_r1ef2a0ae815fa433_000001401128cb0b_1
… (36s) Current
status: DONE
All table write operations in a job happen atomically at the end of the job.
That is, when the job completes, either all write operations are performed
at once or none of them are. For example, if you use WRITE_TRUNCATE ,
there will be no period of time when the table is empty—other callers will
either see all the original data or all the replaced data. Moreover, if there is a
WRITE_APPEND job happening at the same time as a WRITE_TRUNCATE job
is running, the expected behavior depends on which one finishes first. If the
append completes first, the truncate also truncates the appended data. If the
truncate job completes first, the appended data will be present in the table
along with the results of the truncate job.
Job Status
Job status entries have three fields: state , errorResult , and errors .
The state is the state the current job is in; jobs start as PENDING , progress
to RUNNING when they are actually being acted upon, and then are marked
DONE when the job completes. There is no error state. If the job failed, the
state will still be DONE , but the errorResult field will be populated. Figure
4.6 shows the usual job state transitions, both when the job runs successfully
and when there is an error.
 
Search WWH ::




Custom Search