-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid batch api to carto create table #1731
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@jgoizueta, is there any inconvenience creating tables without the Batch API?
🤔 I see no problem in principle, LGTM. |
Thank you both!! @Jesus89 it is our understanding that the However, do you think it'd make sense to implement this approach in the def _truncate_table(self, table_name, schema, cartodbfy):
log.debug('TRUNCATE table "{}"'.format(table_name))
query = 'BEGIN; {truncate}; {cartodbfy}; COMMIT;'.format(
truncate=_truncate_table_query(table_name),
cartodbfy=_cartodbfy_query(table_name, schema) if cartodbfy else '')
self.execute_query(query) >>> gdf = cartoframes.read_carto('select * from table_name limit 5')
>>> cartoframes.to_carto(gdf, 'table_name', if_exists='replace')
Success! Data uploaded to table "table_name" correctly
'table_name' |
It's a quick operation (truncate_table) so I think it could use the single SQL API, yes. |
Added the change for the |
👍 |
Context
In this small PR from Support we aim to avoid an undesired behavior when using the
to_carto
function while a Batch API job is already running, by using the standard SQL API endpoint when possible.If the table wouldn't exist in the target CARTO account, it'd be created through the
_create_table_from_columns
method which seems to be using the Batch API for what seems a light operation (create table + cartodbfy an empty table).This could lead to an undesired behavior if there is an active long-time running job, as the referred operation would be enqueued.
Further details can be found in this CH story.
PR changes
execute_query
instead ofexecute_long_running_query
in_create_table_from_columns
execute_query
is ran instead ofexecute_long_running_query
intest_copy_from