The TD Toolbelt Reference and additional TD Toolbelt documentation can be found on the Treasure Data Developer Portal.
Typically, when using the TD Toolbelt to run a query you want to wait for the job to complete.
If you issue a query without using the -w option, the command ends immediately after submitting the job.
$ td query [sql] options:
-d, --database DB_NAME use the database (required)
-w, --wait[=SECONDS] wait for finishing the job (for seconds)
-G, --vertical use vertical table to show results
-o, --output PATH write result to the file
-f, --format FORMAT format of the result to write to the file (tsv, csv, json, msgpack, and msgpack.gz)
-r, --result RESULT_URL write result to the URL (see also result:create subcommand)
It is suggested for this option to be used with the -x / --exclude option to suppress printing
of the query result to stdout or -o / --output to dump the query result into a file.
-u, --user NAME set user name for the result URL
-p, --password ask password for the result URL
-P, --priority PRIORITY set priority
-R, --retry COUNT automatic retrying count
-q, --query PATH use file instead of inline query
-T, --type TYPE set query type (hive, presto)
--sampling DENOMINATOR OBSOLETE - enable random sampling to reduce records 1/DENOMINATOR
-l, --limit ROWS limit the number of result rows shown when not outputting to file
-c, --column-header output of the columns' header when the schema is available for the table (only applies to json, tsv and csv formats)
-x, --exclude do not automatically retrieve the job result
-O, --pool-name NAME specify resource pool by name
--domain-key DOMAIN_KEY optional user-provided unique ID. You can include this ID with your `create` request to ensure idempotence
--engine-version ENGINE_VERSION
EXPERIMENTAL: specify query engine version by name For example, use the -w option:
$ td query -w -d testdb "SELECT COUNT(1) FROM www_access"Job 702 is started.
If you issue a query without using the -w option, the command ends immediately after submitting the job. For example:
$ td query -d testdb "SELECT COUNT(1) FROM www_access"Job 704 is started.Use 'td job 704' to show the status.
You can output the job results into local disk as CSV format, instead of STDOUT.
$ td query -o test.csv --format csv -w -d testdb 'SELECT COUNT(1) FROM www_access'Status : successResult : written to test.csv in csv format
The td jobs command lists your submitted jobs. The most recent 20 jobs are shown by default.
$ td job:list [max] options:
-p, --page PAGE skip N pages
-s, --skip N skip N jobs
-R, --running show only running jobs
-S, --success show only succeeded jobs
-E, --error show only failed jobs
--slow [SECONDS] show slow queries (default threshold: 3600 seconds)
-f, --format FORMAT format of the result rendering (tsv, csv, json or table. default is table)| command example | to view |
|---|---|
| $ td jobs -p 0 | the most recent 20 jobs |
| $ td jobs -p 1 | jobs 21-40 |
| $ td jobs -p 2 | jobs 41-60 |
The command shows a specific job’s detailed information.
$ td job 10349872 For example:
