-
Notifications
You must be signed in to change notification settings - Fork 63
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
Bug/ch155055/emily mo inconsistent to carto error #1734
Bug/ch155055/emily mo inconsistent to carto error #1734
Conversation
…olumns copy_from strategy to avoid payload limit
This pull request has been linked to Clubhouse Story #155055: [emily-mo] Inconsistent to_carto error. |
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.
Nice job. It is a very ingenious solution :)
However, I would check the payload size before going that way because it requires two extra queries. So for every normal situation, it would work the same (with no extra requests) but then the len(query) > X
this system can be done.
Regarding the X
, the length of the query and the payload of the request are very similar. but instead of using "16384" (which is the limit of the Batch API) we could use 12000 just to make sure there are no false negatives.
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, nice job!
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.
I have added a comment to improve readability
Performed different Q&A tests on both an enterprise and a free plan accounts and it seems to be working as expected. Thank you a lot for the great CR @Jesus89 @jgoizueta ❤️ |
Context
In this small PR from Support we aim to avoid hitting the Batch API 16 kb payload limit when using the
_truncate_and_drop_add_columns
function, which is called fromto_carto
(throughcopy_from
) withif_exists='replace'
collision strategy if the table structure changes used and the table has a considerable amount of columns.Further context can be found here: https://app.clubhouse.io/cartoteam/story/155055/emily-mo-inconsistent-to-carto-error
Proposed solution
Example output with the current logic
Example output with the changes implemented
We have also verified that the temporary function is dropped as expected.
PR changes
Relevant
io/managers/context_manager.py
where the logic referred above is implemented. Add helper functions for query definition, add functions to create and drop UDFs and perform necessary changes in the_truncate_and_drop_add_columns
functionMinor
utils/utils.py
add a functioncreate_tmp_name
to create temporary-like names using uuid/data/services/service.py
adapt the_new_temporary_table_name
method to make use of thecreate_tmp_name
function