The samples shown in this page access your data through the Treasure Data REST API.

Description

URI

create a new table in the database

table/create/:database_name/:new_table_name

create a new table in the database and register it in PlazmaDB

table/create/:database_name/:new_table_name/log

delete a specified table

table/delete/:database_name/:table_name

update a specified table with the information indicated in the parameters

table/update/:database_name/:table_name

get information about a user defined partition that has an index column

table/distribution/:database_name/:table_name

change the table's database

table/change_database/:database_name/:table_name

stream import the contents of the table with the given data format

table/import/:database_name/:table_name/:data_format

stream import the contents of the table with the given data format and give it a unique id

table/import_with_id/:database_name/:table_name/:unique_id/:data_format

get a list of tables in a specified database

table/list/:database_name

create a job to partially delete the contents of a table within a given time range

table/partialdelete/:database_name/:table_name

rename a specified table

table/rename/:database_name/:table_name/:new_name

get the details of a specified table

table/show/:database_name/:table_name

swap two specified tables in the same database with each other and exchange their names

table/swap/:database_name/:table1_name/:table2_name

change the contents of the table to a reverse chronological order based on the registered time (last data first) and return it in the specified format

table/tail/:database_name/:table_name

update the table by appending columns to the schema generating a new alias (if necessary)

table/append-schema/:database_name/:table_name

update the table schema

table/update-schema/:database_name/:table_name


table/create/:database_name/:new_table_name

This is the API that creates a new table in the database.

Verb

URI

POST

/v3/table/create/:database_name/:new_table_name(.:format)

URI Parameters

Parameter Name

Description

database_name

Name of the target database

new_table_name

Name of the new table to be created


Sample Request

$ curl -X POST \ 
    https://api.treasuredata.com/v3/table/create/t_test_db/t_table_2_via_api \ 
    -H 'Authorization: TD1 <API Key>'

Sample Response Success

{ "database": "t_test_db", "table": "t_table_2_via_api", "type": "log" }

Sample Request with Failure

$ curl -X POST \ https://api.treasuredata.com/v3/table/create/t_test_db/t_table_2_via_api \-H 'Authorization: TD1 <API Key>'

Sample Response with Failure

{ "error": "Resource not found", "message": "Resource not found", "text": "Resource not found", "severity": "error", "status_code": 404 }

table/create/:database_name/:new_table_name/log

This is the API that creates a new table in the database and registers it in PlazmaDB. It is recommended that table/create/:database_name/:new_table_name/log be used instead of v3/table/create/:database_name/:new_table_name.

Verb

URI

POST

/v3/table/create/:database_name/:new_table_name/log(.:format)

URI Parameters

Parameter Name

Description

database_name

Name of target database

new_table_name

Name of new table to be created

Sample Request

$ curl -X POST \
 https://api.treasuredata.com/v3/table/create/t_test_db/t_table_a2/log \ -H 'Authorization: TD1 <API Key>'

Sample Response Success

{ "database": "t_test_db", "table": "t_table_a2", "type": "log" }

Sample Request with Failure

$ curl -X POST \
    https://api.treasuredata.com/v3/table/create/t_test_dbaaa/t_table_a4/log \ 
    -H 'Authorization: TD1 <API Key>'

Sample Response with Failure

{ "error": "Resource not found", "message": "Resource not found", "text": "Resource not found", "severity": "error", "status_code": 404 }

table/delete/:database_name/:table_name

API that deletes the specified table.

Verb

URI

POST

/v3/table/delete/:database_name/:table_name(.:format)

URI Parameters

Parameter Name

Description

database_name

Name of the target database

new_table_name

Name of table to be deleted

Sample Request

$ curl -X POST \
       https://api.treasuredata.com/v3/table/delete/t_test_db_2/t_table_2 \ 
       -H 'Authorization: TD1 <API Key>'

Sample Response Success

{ "database": "t_test_db_2", "table": "t_table_2", "type": "log" }

Sample Request with Failure

$ curl -X POST \
    https://api.treasuredata.com/v3/table/delete/t_test_db_2/t_table_2 \ 
    -H 'Authorization: TD1 <API Key>'

Sample Response with Failure

 { "error": "Resource not found", "message": "Resource not found", "text": "Resource not found", "severity": "error", "status_code": 404 }

table/update/:database_name/:table_name

This API updates a specified table with the information indicated in the parameters.

Verb

URI

POST

/v3/table/create/:database_name/:table_name(.:format)


URI Parameters

Parameter Name

Description

database_name

Name of the target database

new_table_name

Name of table to be deleted

Request Parameters

Parameter Name

Required

Type

Description

Example

name

N

String

New table name

table1_new_name

schema

N

String

Contains a JSON string of the schema to be updated.

Format:

[

[

"member_id", // column name

"string", // data type

"member_id"// alias

],

[

"row_index", // column name

"long", //data type

"row_index"// alias

]

]

[["col1","int","col1"],["col2","string","col2"]]

include_v

N

Boolean

Mainly used for Hive and Wish customers. Not available for other customers.

false

expire_days

N

Integer

Number of days where the contents of the specified table would expire

30

detect_schema

N

Boolean

  • false - the table schema would be fixed and would not be updated automatically.

  • true - when a new is column is detected, schema would be automatically updated.

false

overwrite

N

Boolean

If true, it will overwrite the table with the same name given that the existing table does not have delete protection

true

Sample Request Update Table Name

$ curl -X POST \
    https://api.treasuredata.com/v3/table/update/t_test_db/t_table_b1?name=table_b1_via_api \ 
    -H 'Authorization: TD1 <API Key>'

Sample Response Success

{ "database": "t_test_db", "table": "t_table_b1_via_api", "type": "log" }

Sample Request

$ curl -X POST \
    https://api.treasuredata.com/v3/table/update/t_test_db/t_table_a1?schema=[["col1","int","col1"],["col2","string","col2"]] \ 
    -H 'Authorization: TD1 <API Key>'

Sample Response Success

{ "database": "t_test_db", "table": "t_table_a1", "type": "log" }

Sample Request with Failure

$ curl -X POST \
    https://api.treasuredata.com/v3/table/update/t_test_db_2/t_table_2 \ 
    -H 'Authorization: TD1 <API Key>'

table/distribution/:database_name/:table_name

This API gets information about a user-defined partition that has an index column. The specified table should exists in table_distributions table.

Verb

URI

GET

/v3/table/distribution/:database_name/:table_name(.:format)


URI Parameters

Parameter Name

Description

database_name

Name of the target database

table_name

Name of table to be deleted

Sample Request

$ curl -X GET \
    https://api.treasuredata.com/v3/table/distribution/tpch_s1/test_partition_customer \ 
    -H 'Authorization: TD1 <API Key>'

Sample Response Success

{ "bucket_count": 1024, "partition_function": "hash", "columns": [ { "key": "c_nationkey", "type": "long", "name": "c_nationkey" }] }

Sample Request with Failure

$ curl -X GET \
    https://api.treasuredata.com/v3/table/distribution/t_test_db/t_table_2 \ 
    -H 'Authorization: TD1 <API Key>'

Sample Response with Failure

{ "error": "Resource not found", "message": "Resource not found", "text": "Resource not found", "severity": "error", "status_code": 404 }

table/change_database/:database_name/:table_name

This API changes the table's database.

Verb

URI

POST

/v3/table/change_database/:database_name/:table_name(.:format)


URI Parameters

Parameter Name

Description

database_name

Name of the target database

table_name

Name of the target table

Request Parameters

Parameter Name

Required

Type

Description

Example

dest_database_name

Y

String

Output format of the table information

db_name_new

Sample Request

$ curl -X POST \
    https://api.treasuredata.com/v3/table/change_database/t_test_db/t_table_2?dest_database_name=thyra_test_db_2 \ 
    -H 'Authorization: TD1 <API Key>'

Sample Response Success

{ "database": "t_test_db_2", "table": "t_table_2", "type": "log"}

Sample Request

$ curl -X POST \
    https://api.treasuredata.com/v3/table/change_database/t_test_db/t_table_2?dest_database_name=thyra_test_db_2 \ 
    -H 'Authorization: TD1 <API Key>'

Sample Response with Failure

{ "error": "Resource not found", "message": "Resource not found", "text": "Resource not found", "severity": "error", "status_code": 404 }

table/import/:database_name/:table_name/:data_format

API that streaming imports the contents of the table with the given data format. Only the msgpack.gz data format is supported.

Verb

URI

PUT

/v3/table/import/:database_name/:table_name/:data_format(.:format)


URI Parameters

Parameter Name

Description

database_name

Name of the target database

table_name

Name of the target table

data_format

The following is supported:

msgpack.gz

Sample Request

$ curl -X PUT \
    https://api.treasuredata.com/v3/table/import/t_test_db/t_table_a1/msgpack.gz \
    -H 'Authorization: TD1 <API Key>' \
    -H 'Content-Type: application/octet-stream' \
    --data-binary @filename.msgpack.gz

Sample Response Success

{ "unique_id": "51f7d4004c4b11e9b7dd0a601dcd1f1e", "md5_hex": "d41d8cd98f00b204e9800998ecf8427e", "database": "t_test_db", "table": "t_table_a1", "elapsed_time": 0}

Sample Request with Failure

$ curl -X PUT \
    https://api.treasuredata.com/v3/table/import/t_test_dbaaa/t_table_a1/msgpack.gz \
    -H 'Authorization: TD1 <API Key>' \
    -H 'Content-Type: application/octet-stream' \
    --data-binary @filename.msgpack.gz

Sample Response with Failure

{ "error": "Resource not found", "message": "Resource not found", "text": "Resource not found", "severity": "error", "status_code": 404 }

table/import_with_id/:database_name/:table_name/:unique_id/:data_format

API that streaming imports the contents of the table with the given data format and giving it a unique id. Only msgpack.gz data format is supported.

Verb

URI

PUT

/v3/table/import_with_id/:database_name/:table_name/:unique_id/:data_format(.:format)


URI Parameters

Parameter Name

Description

database_name

Name of the target database

table_name

Name of the target table

unique_id

User-specified unique id of the imported data

data_format

The following is supported:

  • msgpack.gz

Sample Request

$ curl -X PUT \
    https://api.treasuredata.com/v3/table/import_with_id/t_test_db/t_table_a1/uid_20190322/msgpack.gz \
    -H 'Authorization: TD1 <API Key>' \
    -H 'Content-Type: application/octet-stream' \
    --data-binary @filename.msgpack.gz

Response Collapse source

{ "unique_id": "bc2fe648e4dbbe82f58c5ddf9b4ac920", "md5_hex": "d41d8cd98f00b204e9800998ecf8427e", "database": "t_test_db", "table": "t_table_a1", "elapsed_time": 0 }

Sample Request with Failure

$ curl -X PUT \
    https://api.treasuredata.com/v3/table/import_with_id/t_test_dbaaa/t_table_a1/uid_20190322/msgpack.gz \
    -H 'Authorization: TD1 <API Key>' \
    -H 'Content-Type: application/octet-stream' \
    --data-binary @filename.msgpack.gz

Sample Response with Failure

{ "error": "Resource not found", "message": "Resource not found", "text": "Resource not found", "severity": "error", "status_code": 404 }

table/list/:database_name

This API gets a list of tables in a specified database.

Verb

URI

GET

/v3/table/list/:database_name(.:format)


URI Parameters

Parameter Name

Description

database_name

Name of the target database

Sample Request

$ curl -X GET \
    https://api.treasuredata.com/v3/table/list/t_test_db \
    -H 'Authorization: TD1 <API Key>'

Sample Response Success

{ "database": "t_test_db", "tables": [ { "id": 6773355, "name": "t_table_1", "estimated_storage_size": 0, "counter_updated_at": null, "last_log_timestamp": null, "delete_protected": false, "created_at": "2019-03-06 09:00:30 UTC", "updated_at": "2019-03-06 09:00:30 UTC", "type": "log", "include_v": true, "count": 0, "schema": "[]", "expire_days": null } ] } 

table/partialdelete/:database_name/:table_name

This API creates a job to partially delete the contents of a table within a given time range.

Verb

URI

POST

/v3/table/partialdelete/:database_name/:table_name(.:format)


URI Parameters

Parameter Name

Description

database_name

Name of the target database

table_name

Name of the target table

Request Parameters

Parameter Name

Required

Type

Description

Example

from

Y

Integer

Time in Unix Epoch format indicating the Start date and time of the data to be deleted.

Should be set only by the hour. Minutes and seconds values will not be accepted.

1553058000

to

Y

Integer

Time in Unix Epoch format indicating the End date and time of the data to be deleted.

Should be set only by the hour. Minutes and seconds values will not be accepted.

1553058000

pool_name

N

String

Indicates the resource pool to execute this job. If not provided, the account's default resource pool would be used

pool1

domain_key

N

String

Domain key that will be assigned to the partial delete job to be created

20190322_key

Sample Request

$ curl -X POST \
    https://api.treasuredata.com/v3/table/partialdelete/t_test_db/t_table_a1?from=1553054400&amp;to=1553058000 \
    -H 'Authorization: TD1 <API Key>'

Sample Response Success

{ "job_id": 41419592, "database": "t_test_db", "table": "t_table_a1", "from": 1553054400, "to": 1553058000 }

Sample Request with Failure

$ curl -X POST \
    https://api.treasuredata.com/v3/table/partialdelete/t_test_db/t_table_a1a?from=1553054442&amp;to=1553054442 \
    -H 'Authorization: TD1 <API Key>'

Sample Response with Failure

{ "error": "Resource not found", "message": "Resource not found", "text": "Resource not found", "severity": "error", "status_code": 404 }

Sample Request with Error

$ curl -X POST \
    https://api.treasuredata.com/v3/table/partialdelete/t_test_db/t_table_a1?from=1553054541&amp;to=1553054442 \
    -H 'Authorization: TD1 <API Key>'

Sample Response with Failure

{ "error": "[\"From must be on the hour\", \"To can not be less than from\", \"To must be on the hour\"]", "message": "[\"From must be on the hour\", \"To can not be less than from\", \"To must be on the hour\"]", "text": "[\"From must be on the hour\", \"To can not be less than from\", \"To must be on the hour\"]", "severity": "error", "status_code": 422 }

table/rename/:database_name/:table_name/:new_name

This API renames the specified table.

Verb

URI

POST

/v3/table/rename/:database_name/:table_name/:new_name(.:format)


URI Parameters

Parameter Name

Description

database_name

Name of the target database

table_name

Name of the target table

new_name

New table name

Sample Request

$ curl -X POST \
    https://api.treasuredata.com/v3/table/database1/table1/table1_newname \
    -H 'Authorization: TD1 <API Key>'

Sample Response Success

{ "database": "database1", "table": "table1_newname", "type": "log" }

Sample Request with Failure

$ curl -X POST \
    https://api.treasuredata.com/v3/table/update/t_test_db/t_table_a1z?name=table_1_rename \
    -H 'Authorization: TD1 <API Key>'

Sample Response with Failure

{ "error": "Resource not found", "message": "Resource not found", "text": "Resource not found", "severity": "error", "status_code": 404 }

table/show/:database_name/:table_name

This API gets the details of the specified table.

Verb

URI

GET

/v3/table/show/:database_name/:table_name(.:format)


URI Parameters

Parameter Name

Description

database_name

Name of the target database

table_name

Name of the target table

Sample Request

$ curl -X GET \
    'https://api.treasuredata.com/v3/table/show/benchmark/streaming_import' \
    -H 'Authorization: TD1 <API Key>'

Sample Response Success

{ "id": 441888, "name": "streaming_import", "estimated_storage_size": 7062770, "counter_updated_at": "2015-11-26T07:59:03Z", "last_log_timestamp": "2015-11-26T07:56:29Z", "delete_protected": false, "created_at": "2015-11-26 07:56:11 UTC", "updated_at": "2017-04-13 05:47:51 UTC", "type": "log", "include_v": true, "count": 300000, "schema": "[[\"session\",\"string\"],[\"item_id\",\"long\"],[\"action\",\"string\"],[\"path\",\"string\"],[\"device\",\"string\"],[\"user_agent\",\"string\"],[\"method\",\"string\"],[\"user_id\",\"long\"]]", "expire_days": null }

table/swap/:database_name/:table1_name/:table2_name

This API swaps two specified tables in the same database with each other and basically exchanges their names.

Verb

URI

POST

/v3/table/swap/:database_name/:table1_name/:table2_name(.:format)


URI Parameters

Parameter Name

Description

database_name

Name of the target database

table1_name

Name of first target table for the swap

table2_name

Name of second target table for the swap

Sample Request Success

$ curl -X POST \
    https://api.treasuredata.com/v3/table/swap/t_test_db/t_table_a1/t_table_b1 \
    -H 'Authorization: TD1 <API Key>'

Sample Response Success

{ "database": "t_test_db", "table1": "t_table_b1", "table2": "t_table_a1" }

Sample Request with Failure

$ curl -X POST \
    https://api.treasuredata.com/v3/swap/database1/table1/table2 \
    -H 'Authorization: TD1 <API Key>'

Sample Response with Failure

{ "error": "Path and method do not match any API endpoint", "message": "Path and method do not match any API endpoint", "text": "Path and method do not match any API endpoint", "severity": "error", "status_code": 404 }

table/tail/:database_name/:table_name

This API changes the contents of the table to a reverse chronological order based on the registered time (last data first) and returns it in the specified format.

Verb

URI

GET

/v3/table/tail/:database_name/:table_name(.:format)


URI Parameters

Parameter Name

Description

database_name

Name of the target database

table_name

Name of the target table

Request Parameters

Name

Required

Type

Default

Values

Description

Example

format

N

String

JSON

JSON

msgpack

Output format of the table information

JSON

Sample Request

$ curl -X GET \ 
    https://api.treasuredata.com/v3/table/tail/k_test_db/tail_import2 \ 
    -H 'Authorization: TD1 <API Key>'

Sample Response Success

 [{"col5":15214,"col4":11555,"col7":30613,"time":32766,"col6":4894,"col1":8571,"col3":10990,"col2":5462,"action":"tail","col9":30607,"col8":21026,"user":32766},{"col5":3857,"col4":19760,"col7":16889,"time":32766,"col6":6453,"col1":12239,"col3":29741,"col2":21223,"action":"tail","col9":818,"col8":15029,"user":32766},{"col5":26719,"col4":15663,"col7":8449,"time":32766,"col6":20122,"col1":5471,"col3":15605,"col2":1278,"action":"tail","col9":18512,"col8":25955,"user":32766},{"col5":24449,"col4":31966,"col7":7413,"time":32766,"col6":10745,"col1":2249,"col3":18491,"col2":16347,"action":"tail","col9":14575,"col8":15702,"user":32766},{"col5":28884,"col4":8696,"col7":25928,"time":32766,"col6":27589,"col1":16429,"col3":23759,"col2":5596,"action":"tail","col9":11488,"col8":29877,"user":32766},{"col5":4395,"col4":28862,"col7":29659,"time":32766,"col6":26107,"col1":24077,"col3":28074,"col2":26724,"action":"tail","col9":31244,"col8":25493,"user":32766},{"col5":16014,"col4":12288,"col7":28942,"time":32766,"col6":11570,"col1":224,"col3":29376,"col2":30570,"action":"tail","col9":3782,"col8":12700,"user":32766},{"col5":3617,"col4":4405,"col7":3385,"time":32766,"col6":1861,"col1":2359,"col3":12639,"col2":6592,"action":"tail","col9":17938,"col8":22788,"user":32766},{"col5":23784,"col4":6922,"col7":27397,"time":32766,"col6":14426,"col1":11552,"col3":13360,"col2":31178,"action":"tail","col9":7144,"col8":205,"user":32766},{"col5":15482,"col4":7416,"col7":22638,"time":32766,"col6":10623,"col1":32066,"col3":7978,"col2":24736,"action":"tail","col9":8531,"col8":9725,"user":32766},{"col5":21047,"col4":8522,"col7":29510,"time":32766,"col6":23020,"col1":23747,"col3":26230,"col2":8183,"action":"tail","col9":1198,"col8":18906,"user":32766},{"col5":21982,"col4":19859,"col7":10312,"time":32766,"col6":26777,"col1":4118,"col3":10101,"col2":23182,"action":"tail","col9":28362,"col8":32760,"user":32766},{"col5":16417,"col4":3052,"col7":17547,"time":32766,"col6":19297,"col1":24376,"col3":3623,"col2":2322,"action":"tail","col9":19496,"col8":14924,"user":32766},{"col5":26187,"col4":19529,"col7":12700,"time":32766,"col6":4585,"col1":22748,"col3":10455,"col2":14404,"action":"tail","col9":16255,"col8":12190,"user":32766},{"col5":17999,"col4":23411,"col7":29959,"time":32766,"col6":2603,"col1":29385,"col3":29614,"col2":26566,"action":"tail","col9":28270,"col8":12590,"user":32766},{"col5":8466,"col4":2359,"col7":15796,"time":32766,"col6":4746,"col1":30677,"col3":21707,"col2":5575,"action":"tail","col9":17430,"col8":2318,"user":32766},{"time":32767,"action":"tail","user":32767},{"time":32767,"action":"tail","user":32767},{"time":32767,"action":"tail","user":32767},{"time":32767,"action":"tail","user":32767},{"time":32767,"action":"tail","user":32767},{"time":32767,"action":"tail","user":32767},{"time":32767,"action":"tail","user":32767},{"time":32767,"action":"tail","user":32767},{"time":32767,"action":"tail","user":32767},{"time":32767,"action":"tail","user":32767},{"time":32767,"action":"tail","user":32767},{"time":32767,"action":"tail","user":32767},{"time":32767,"action":"tail","user":32767},{"time":32767,"action":"tail","user":32767},{"time":32767,"action":"tail","user":32767},{"time":32767,"action":"tail","user":32767},{"col5":31683,"col4":3872,"col7":20514,"time":32767,"col6":9464,"col1":9415,"col3":30721,"col2":24234,"action":"tail","col9":22349,"col8":13804,"user":32767},{"col5":20651,"col4":3786,"col7":19243,"time":32767,"col6":30803,"col1":14100,"col3":18852,"col2":14396,"action":"tail","col9":9910,"col8":23162,"user":32767},{"col5":12234,"col4":27068,"col7":15988,"time":32767,"col6":26305,"col1":21378,"col3":10032,"col2":16018,"action":"tail","col9":16431,"col8":21513,"user":32767},{"col5":22383,"col4":26955,"col7":3600,"time":32767,"col6":20349,"col1":10261,"col3":17478,"col2":22050,"action":"tail","col9":10827,"col8":18541,"user":32767},{"col5":22316,"col4":11767,"col7":15725,"time":32767,"col6":9858,"col1":32538,"col3":27957,"col2":16974,"action":"tail","col9":7628,"col8":29145,"user":32767},{"col5":19613,"col4":12903,"col7":19439,"time":32767,"col6":11608,"col1":18886,"col3":31915,"col2":5240,"action":"tail","col9":15551,"col8":3252,"user":32767},{"col5":24164,"col4":10799,"col7":14009,"time":32767,"col6":29182,"col1":12824,"col3":21901,"col2":11074,"action":"tail","col9":30767,"col8":26708,"user":32767},{"col5":12958,"col4":20746,"col7":30272,"time":32767,"col6":15554,"col1":12912,"col3":11495,"col2":25202,"action":"tail","col9":11657,"col8":24008,"user":32767}]

Sample Request with Failure

$ curl -X GET \
    https://api.treasuredata.com/v3/table/tail/benchmark/table1 \
    -H 'Authorization: TD1 <API Key>'

Sample Response with Failure

{ "error": "Resource not found", "message": "Resource not found", "text": "Resource not found", "severity": "error", "status_code": 404 }

table/append-schema/:database_name/:table_name

This API updates the table by appending columns to the schema generating a new alias if necessary.

Verb

URI

POST

/v3/table/append-schema/:database_name/:table_name(.:format)


URI Parameters

Parameter Name

Description

database_name

Name of target database

table_name

Name of target table

Request Parameters

Parameter Name

Required

Type

Description

Example

schema

N

String

Contains a JSON string of the schema to be updated

Format:


[

[

"member_id", // column name

"string", // data type

"member_id"// alias

],

[

"row_index", // column name

"long", //data type

"row_index"// alias

]

]

[["col1","int","col1"],["col2","string","col2"]]

Sample Request

$ curl -g -X POST \
    'https://api.treasuredata.com/v3/table/append-schema/t_test_db/t_table_a1?schema=[["col5","double","col5"]]' \
    -H 'Authorization: TD1 <API Key>'

Sample Response Success

{ "database": "t_test_db", "table": "t_table_a1", "type": "log" }

Sample Request

$ curl -X POST \
    https://api.treasuredata.com/v3/table/append-schema/t_test_db/t_table_zzz?schema=[["col4","boolean","col4"]] \
    -H 'Authorization: TD1 <API Key>'

Sample Response Success

{ "error": "Resource not found", "message": "Resource not found", "text": "Resource not found", "severity": "error", "status_code": 404 }

Sample Request with Failure

$ curl -X POST \
    https://api.treasuredata.com/v3/table/append-schema/t_test_db/t_table_a1?schema=[["col4","boolean","col4"]] \
    -H 'Authorization: TD1 <API Key>'

Sample Response with Failure

{ "error": "Parameters are invalid", "message": "Parameters are invalid", "text": "Parameters are invalid", "severity": "error", "status_code": 422 }

table/update-schema/:database_name/:table_name

This API updates the table schema.

Verb

URI

POST

/v3/table/update-schema/:database_name/:table_name(.:format)


URI Parameters

Parameter Name

Description

database_name

Name of the target database

table_name

Name of the target table

Request Parameters

Name

Required

Type

Description

Example

name

N

String

New table name

table1_new_name

schema

N

String

Contains a JSON string of the schema to be updated

Format:


[

[

"member_id", // column name

"string", // data type

"member_id"// alias

],

[

"row_index", // column name

"long", //data type

"row_index"// alias

]

]

[["col1","int","col1"],["col2","string","col2"]]

include_v

N

Boolean

Mainly used for Hive customers.

false

expire_days

N

Integer

Number of days where the contents of the specified table would expire

30

detect_schema

N

Boolean

  • false - the table schema would be fixed and would not be updated automatically.

  • true - when a new is column is detected, schema would be automatically updated.

false

overwrite

N

Boolean

If true, it will overwrite the table with the same name given that the existing table does not have delete protection

true

Sample Request

$ curl -g -X POST \
    'https://api.treasuredata.com/v3/table/update-schema/t_test_db/t_table_a1?schema=[["col2","int","col2"],["col3","string","col3"]]' \
    -H 'Authorization: TD1 <API Key>'

Sample Response Success

{ "database": "t_test_db", "table": "t_table_a1", "type": "log" }

Sample Request with Failure

$ curl -X POST \
    https://api.treasuredata.com/v3/table/update-schema/t_test_db/t_table_zzz?schema=[["col2","int","col2"],["col3","string","col3"]] \
    -H 'Authorization: TD1 <API Key>'

Sample Response with Failure

{ "error": "Resource not found", "message": "Resource not found", "text": "Resource not found", "severity": "error", "status_code": 404 }
  • No labels