Title: | Simple TD API Client |
---|---|
Description: | Upload R data.frame to Arm Treasure Data, see <https://www.treasuredata.com/>. You can execute database or table handling for resources on Arm Treasure Data. |
Authors: | Aki Ariga [aut, cre, cph] |
Maintainer: | Aki Ariga <[email protected]> |
License: | Apache License 2.0 | file LICENSE |
Version: | 0.4.1.900 |
Built: | 2025-03-12 05:00:09 UTC |
Source: | https://github.com/treasure-data/rtd |
Delete bulk import part
bulk_import_delete_part(conn, name, part_name)
bulk_import_delete_part(conn, name, part_name)
conn |
|
name |
Bulk import session name |
part_name |
Bulk import part name |
Return TRUE
if succeeded
## Not run: conn <- Td(apikey = "xxxx") bulk_import_delete_part(conn, sess_name, "part") ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") bulk_import_delete_part(conn, sess_name, "part") ## End(Not run)
Show bulk import error records
bulk_import_error_records(conn, name)
bulk_import_error_records(conn, name)
conn |
|
name |
Bulk import session name |
Return error records in gzipped file with msgpack stream format.
## Not run: conn <- Td(apikey = "xxxx") bulk_import_error_records(conn, sess_name) ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") bulk_import_error_records(conn, sess_name) ## End(Not run)
Upload bulk import part
bulk_import_upload_part(conn, name, part_name, file_obj)
bulk_import_upload_part(conn, name, part_name, file_obj)
conn |
|
name |
Bulk import session name |
part_name |
Bulk import part name |
file_obj |
File connection. Should be msgpack stream with gzip compressed. Should have "time" column |
Return bulk import status
## Not run: conn <- Td(apikey = "xxxx") ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") ## End(Not run)
Commit bulk import part
commit_bulk_import(conn, name)
commit_bulk_import(conn, name)
conn |
|
name |
Bulk import session name |
Return TRUE
if succeeded
## Not run: conn <- Td(apikey = "xxxx") commit_bulk_import(conn, sess_name) ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") commit_bulk_import(conn, sess_name) ## End(Not run)
Create bulk import
create_bulk_import(conn, name, dbname, table)
create_bulk_import(conn, name, dbname, table)
conn |
|
name |
Bulk import session name |
dbname |
Data base name |
table |
Table name |
Return TRUE
if succeeded
## Not run: conn <- Td(apikey = "xxxx") sess_name <- uuid::UUIDgenerate() create_bulk_import(conn, sess_name, "mydb", "mytable") ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") sess_name <- uuid::UUIDgenerate() create_bulk_import(conn, sess_name, "mydb", "mytable") ## End(Not run)
Create a database
create_database(conn, dbname, params)
create_database(conn, dbname, params)
conn |
|
dbname |
Target data base name |
params |
Optional parameters |
Returns TRUE
or FALSE
, whether the execution succeeded or not.
## Not run: con <- Td(apikey = "xxxxx") create_database(con, "newdb") ## End(Not run)
## Not run: con <- Td(apikey = "xxxxx") create_database(con, "newdb") ## End(Not run)
Create a table
create_table(conn, dbname, table)
create_table(conn, dbname, table)
conn |
|
dbname |
Data base name |
table |
Table name |
Returns TRUE
or FALSE
, whether the execution succeeded or not.
## Not run: conn <- Td(apikey = "xxxx") create_table(conn, "mydb", "new_table") ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") create_table(conn, "mydb", "new_table") ## End(Not run)
Delete bulk import
delete_bulk_import(conn, name)
delete_bulk_import(conn, name)
conn |
|
name |
Bulk import session name |
Return TRUE
if succeeded
## Not run: conn <- Td(apikey = "xxxx") delete_bulk_import(conn, sess_name) ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") delete_bulk_import(conn, sess_name) ## End(Not run)
Delete a database
delete_database(conn, dbname)
delete_database(conn, dbname)
conn |
|
dbname |
Target data base name |
Returns TRUE
or FALSE
, whether the execution succeeded or not.
## Not run: conn <- Td(apikey = "xxxx") delete_database(conn, "mydb") ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") delete_database(conn, "mydb") ## End(Not run)
Delete a table
delete_table(conn, dbname, table)
delete_table(conn, dbname, table)
conn |
|
dbname |
Data base name |
table |
Table name |
Returns TRUE
or FALSE
, whether the execution succeeded or not.
## Not run: conn <- Td(apikey = "xxxxx") delete_table(conn, "mydb", "iris") ## End(Not run)
## Not run: conn <- Td(apikey = "xxxxx") delete_table(conn, "mydb", "iris") ## End(Not run)
Check table existence
exist_database(conn, dbname)
exist_database(conn, dbname)
conn |
|
dbname |
Data base name |
Return TRUE
or FALSE
, existence
## Not run: conn <- Td(apikey = "xxxx") exist_database(conn, "mydb") ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") exist_database(conn, "mydb") ## End(Not run)
Check table existence
exist_table(conn, dbname, table)
exist_table(conn, dbname, table)
conn |
|
dbname |
Data base name |
table |
Table name |
Returns TRUE
or FALSE
, existence.
## Not run: conn <- Td(apikey = "xxxxx") exist_table(conn, "mydb", "iris") ## End(Not run)
## Not run: conn <- Td(apikey = "xxxxx") exist_table(conn, "mydb", "iris") ## End(Not run)
Freeze bulk import part
freeze_bulk_import(conn, name)
freeze_bulk_import(conn, name)
conn |
|
name |
Bulk import session name |
Return TRUE
if succeeded
## Not run: conn <- Td(apikey = "xxxx") freeze_bulk_import(conn, sess_name) ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") freeze_bulk_import(conn, sess_name) ## End(Not run)
List bulk import parts
list_bulk_import_parts(conn, name)
list_bulk_import_parts(conn, name)
conn |
|
name |
Bulk import session name |
Return bulk import parts list
## Not run: conn <- Td(apikey = "xxxx") list_bulk_import_parts(conn, sess_name) ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") list_bulk_import_parts(conn, sess_name) ## End(Not run)
List bulk imports
list_bulk_imports(conn)
list_bulk_imports(conn)
conn |
|
Return bulk import list
## Not run: conn <- Td(apikey = "xxxx") list_bulk_import(conn) ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") list_bulk_import(conn) ## End(Not run)
Show database list
list_databases(conn)
list_databases(conn)
conn |
|
Returns a data.frame
of the database list
## Not run: conn <- Td(apikey = "xxxx") list_databases(conn) ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") list_databases(conn) ## End(Not run)
Show list of tables
list_tables(conn, dbname)
list_tables(conn, dbname)
conn |
|
dbname |
Data base name. Optional, but highly recommended to prevent timeout. |
Returns a data.frame
of a list of tables or FALSE
if not exists.
## Not run: conn <- Td(apikey = "xxxxx") list_tables(conn, "mydb") ## End(Not run)
## Not run: conn <- Td(apikey = "xxxxx") list_tables(conn, "mydb") ## End(Not run)
Perform bulk import part
perform_bulk_import(conn, name)
perform_bulk_import(conn, name)
conn |
|
name |
Bulk import session name |
Return TRUE
if succeeded
## Not run: conn <- Td(apikey = "xxxx") perform_bulk_import(conn, sess_name) ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") perform_bulk_import(conn, sess_name) ## End(Not run)
Show bulk import
show_bulk_import(conn, name)
show_bulk_import(conn, name)
conn |
|
name |
Bulk import session name |
Return bulk import status
## Not run: conn <- Td(apikey = "xxxx") show_bulk_import(conn, sess_name) ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") show_bulk_import(conn, sess_name) ## End(Not run)
Connect to TD
Td(endpoint, apikey, user_agent, headers, http_proxy = NULL)
Td(endpoint, apikey, user_agent, headers, http_proxy = NULL)
endpoint |
Endpoint to TD API |
apikey |
API key for TD |
user_agent |
User-Agent as |
headers |
Default headres in a named |
http_proxy |
HTTP proxy setting. optional. |
## Not run: client <- Td( endpoint = "api.treasuredata.com", apikey = "xxxxxx", http_proxy = "http://user:[email protected]:8080/" ) ## End(Not run)
## Not run: client <- Td( endpoint = "api.treasuredata.com", apikey = "xxxxxx", http_proxy = "http://user:[email protected]:8080/" ) ## End(Not run)
Upload data.frame to TD
td_upload( conn, dbname, table, df, mode = "bulk_import", embulk_dir, overwrite = FALSE, append = FALSE )
td_upload( conn, dbname, table, df, mode = "bulk_import", embulk_dir, overwrite = FALSE, append = FALSE )
conn |
|
dbname |
Target destination database name. |
table |
Target table name. |
df |
Input data.frame. |
mode |
Write mode. "bulk_import" or "embulk". Default: "bulk_import" |
embulk_dir |
Path to embulk. [optional] |
overwrite |
Flag for overwriting the table if exists. It doesn't overwrite database. This flag sets "replace" mode for embulk-output-td. |
append |
Flag for append data into the table if exists. It doesn't overwrite database. This flag sets "append" mode for embulk-output-td. |
## Not run: td_upload_embulk("mydb", "iris", iris) # With overwrite option td_upload_embulk("mydb", "iris", iris, overwrite = TRUE) # With append option td_upload_embulk("mydb", "iris", iris, append = TRUE) # With overwrite option td_upload_embulk("mydb", "iris", iris, "/path/to/embulk", overwrite = TRUE) ## End(Not run)
## Not run: td_upload_embulk("mydb", "iris", iris) # With overwrite option td_upload_embulk("mydb", "iris", iris, overwrite = TRUE) # With append option td_upload_embulk("mydb", "iris", iris, append = TRUE) # With overwrite option td_upload_embulk("mydb", "iris", iris, "/path/to/embulk", overwrite = TRUE) ## End(Not run)
Unfreeze bulk import part
unfreeze_bulk_import(conn, name)
unfreeze_bulk_import(conn, name)
conn |
|
name |
Bulk import session name |
Return TRUE
if succeeded
## Not run: conn <- Td(apikey = "xxxx") unfreeze_bulk_import(conn, sess_name) ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") unfreeze_bulk_import(conn, sess_name) ## End(Not run)
Update schema of a table
update_schema(conn, dbname, table, schema)
update_schema(conn, dbname, table, schema)
conn |
|
dbname |
Data base name |
table |
Table name |
schema |
Schema of the table to be updated |
Returns TRUE
or FALSE
, whether the execution succeeded or not.
## Not run: conn <- Td(apikey = "xxxxx") s <- rbind( c("sepal_length", "double", "sepal_length"), c("sepal_width", "double", "sepal_width"), c("petal_length", "double", "petal_length"), c("petal_width", "double", "petal_width"), c("species", "string", "species")) udpate_schema(conn, "mydb", "iris", s) ## End(Not run)
## Not run: conn <- Td(apikey = "xxxxx") s <- rbind( c("sepal_length", "double", "sepal_length"), c("sepal_width", "double", "sepal_width"), c("petal_length", "double", "petal_length"), c("petal_width", "double", "petal_width"), c("species", "string", "species")) udpate_schema(conn, "mydb", "iris", s) ## End(Not run)
Wait bulk import until finished
wait_bulk_import(conn, sess_name)
wait_bulk_import(conn, sess_name)
conn |
|
sess_name |
Bulk import session name |
## Not run: conn <- Td(apikey = "xxxx") wait_bulk_import(conn, sess_name) ## End(Not run)
## Not run: conn <- Td(apikey = "xxxx") wait_bulk_import(conn, sess_name) ## End(Not run)