Skip to content
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

Feature/ch157435/cartoframes to carto performance evaluation #1735

Conversation

Mmoncadaisla
Copy link
Contributor

Context

In this small PR from Support we aim the following two things:

  1. Increase to_carto performance, further context can be found here: https://app.clubhouse.io/cartoteam/story/157435/cartoframes-to-carto-performance-evaluation
  2. Mitigate a corner case bug on the CDB_TableMetadata_Trigger from the CARTOframes side (except if using to_carto with if_exists='append' on a cartodbfied table), further context could be found here: https://app.clubhouse.io/cartoteam/story/149748/farmers-insurance-admin-duplicate-key-value-violates-unique-constraint-cdb-tablemetadata-pkey-using-to-carto#activity-159580

Proposed solution

Change the order in which the cartodbfication process is being performed, to be performed after the COPY from operation is done to prevent triggers from 1) reducing the overall upload process performance, and 2) potentially raise an unexpected error due to the CDB_TableMetadata_Trigger.

PR changes

  • io/managers/context_manager.py remove the cartodbfication step from the corresponding functions (e.g: create_table_from_query) and perform this step through the Batch API after the copy_from is performed (except if 'append' is used or the user explicitly sets cartodbfy=False in the to_carto function call.
  • tests/unit/io/managers/test_context_manager.py adapt corresponding tests (e.g: test_copy_from_exists_replace_truncate)

@Mmoncadaisla Mmoncadaisla requested a review from Jesus89 June 11, 2021 10:15
@Mmoncadaisla Mmoncadaisla self-assigned this Jun 11, 2021
@shortcut-integration
Copy link

This pull request has been linked to Clubhouse Story #157435: CARTOframes to_carto performance evaluation.

@Mmoncadaisla
Copy link
Contributor Author

cc @pablomoniz

@Mmoncadaisla Mmoncadaisla removed the request for review from Jesus89 June 11, 2021 18:06
@Mmoncadaisla Mmoncadaisla marked this pull request as draft June 11, 2021 18:07
@Mmoncadaisla Mmoncadaisla marked this pull request as ready for review June 14, 2021 15:45
@Mmoncadaisla Mmoncadaisla requested a review from Jesus89 June 14, 2021 15:45
Copy link
Member

@Jesus89 Jesus89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Nice performance research and clean execution

@Mmoncadaisla Mmoncadaisla merged commit 7fd1094 into develop Jun 15, 2021
@Mmoncadaisla Mmoncadaisla deleted the feature/ch157435/cartoframes-to-carto-performance-evaluation branch June 15, 2021 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants