Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Code Block
languagejs
linenumberstrue
File "/usr/local/lib/python3.6/site-packages/tdclient/bulk_import_api.py", line 31, in create_bulk_import self.raise_error("Create bulk import failed", res, body) 
File "/usr/local/lib/python3.6/site-packages/tdclient/api.py", line 367, in raise_error raise errors.AlreadyExistsError("%s: %s" % (msg, s)) 
tdclient.errors.AlreadyExistsError: Create bulk import failed: 
{
  "error":"[\"Name has already been taken\"]",
  "message":"[\"Name has already been taken\"]",
  "text":"[\"Name has already been taken\"]",
  "severity":"error",
  "status_code":409
} 
Table of Contents
maxLevel1

...

Description

create_bulk_import failed with an error.

...

Cause

Job is executing the same exact query twice will cause two distinct queries to be executed on Treasure Data.

Code Block
languageruby
linenumberstrue
print(f'Writing to table {schema_name}.{table_name}') session_name = "session-%d" % (int(time.time()),) 
bulk_import = self.tdclient.create_bulk_import(session_name, schema_name, table_name)

session_name was not unique which caused to fail.

...

Resolution

Submit a job with unique session_name. Add the random number to the session name.

Code Block
languageruby
linenumberstrue
print(f'Writing to table {schema_name}.{table_name}') session_name = "session-%d-%d" % (int(time.time()),random.randint(1,10001)),) 
bulk_import = self.tdclient.create_bulk_import(session_name, schema_name, table_name) 

...

Note / Related Information

https://support.treasuredata.com/hc/en-us/articles/360001260527-REST-API#Job%20Request%20IdempotencyREST APIs in Treasure Data