Database Reference
In-Depth Information
$ for i in $(seq 10); do
echo $i
bq query --append_table
--destination_table=ch11.time_lapse \
"SELECT ${i} index, INTEGER(NOW()/1000) millis"
sleep 10
done
Here you use a query to append a row to a fixed destination table
( ch11.time_lapse ) that includes a timestamp and row index. Each query
run is a job and the jobs are the atom of change that BigQuery tracks. You
cannot reference changes smaller than that made by a single job because
its effect is atomic. Here is what the table looks like after the command
completes:
$ bq head ch11.time_lapse
+-------+---------------+
| index | millis |
+-------+---------------+
| 0 | 0 |
| 1 | 1395214708049 |
| 2 | 1395214719589 |
| 3 | 1395214731135 |
| 4 | 1395214742932 |
| 5 | 1395214754874 |
| 6 | 1395214766503 |
| 7 | 1395214778642 |
| 8 | 1395214790355 |
| 9 | 1395214802060 |
| 10 | 1395214814200 |
+-------+---------------+
The key property to keep in mind is that the millis field of a given record
is approximately the same as (it will be a little before) the completion time
of the query that added it to the table.
The syntax for referencing a time slice of a table is:
< table name >@[-]< start time >[-[< end time >]]
Search WWH ::




Custom Search