Skip to content

Commit

Permalink
Merge pull request #1731 from CartoDB/avoid_batch_api_to_carto_create…
Browse files Browse the repository at this point in the history
…_table

Avoid batch api to carto create table
  • Loading branch information
Mmoncadaisla authored Apr 13, 2021
2 parents 1fbad84 + a0bd8e5 commit a8fab58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cartoframes/io/managers/context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,14 @@ def _create_table_from_columns(self, table_name, schema, columns, cartodbfy):
query = 'BEGIN; {create}; {cartodbfy}; COMMIT;'.format(
create=_create_table_from_columns_query(table_name, columns),
cartodbfy=_cartodbfy_query(table_name, schema) if cartodbfy else '')
self.execute_long_running_query(query)
self.execute_query(query)

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_long_running_query(query)
self.execute_query(query)

def _truncate_and_drop_add_columns(self, table_name, schema, df_columns, table_columns, cartodbfy):
log.debug('TRUNCATE AND DROP + ADD columns table "{}"'.format(table_name))
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/io/managers/test_context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_copy_from(self, mocker):
mocker.patch('cartoframes.io.managers.context_manager._create_auth_client')
mocker.patch.object(ContextManager, 'has_table', return_value=False)
mocker.patch.object(ContextManager, 'get_schema', return_value='schema')
mock_create_table = mocker.patch.object(ContextManager, 'execute_long_running_query')
mock_create_table = mocker.patch.object(ContextManager, 'execute_query')
mock = mocker.patch.object(ContextManager, '_copy_from')
df = DataFrame({'A': [1]})
columns = [ColumnInfo('A', 'a', 'bigint', False)]
Expand Down

0 comments on commit a8fab58

Please sign in to comment.