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

destination-snowflake: truncate large records #45431

Conversation

stephane-airbyte
Copy link
Contributor

@stephane-airbyte stephane-airbyte commented Sep 12, 2024

What

This change implements a large record truncation mechanism for the Snowflake destination connector to handle records exceeding Snowflake's 16MB row size limit.

How

  • The truncator preserves primary key fields and truncates other fields to fit within the 16MB limit.
  • Added metadata to indicate which fields were truncated due to size limitations.

User Impact

Users can now sync large records to Snowflake without encountering errors due to row size limitations. Fields may be truncated to fit within the 16MB limit, but primary keys are always preserved. Metadata is added to indicate which fields were affected.

Copy link

vercel bot commented Sep 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
airbyte-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 18, 2024 10:50pm

@stephane-airbyte stephane-airbyte force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from eb88eff to 36f59f1 Compare September 12, 2024 22:48
@stephane-airbyte stephane-airbyte force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 21c91c5 to 10105cc Compare September 12, 2024 22:48
@stephane-airbyte stephane-airbyte force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from 36f59f1 to 69bf741 Compare September 12, 2024 23:55
@stephane-airbyte stephane-airbyte force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 10105cc to 83e2dda Compare September 12, 2024 23:55
@stephane-airbyte stephane-airbyte force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from 69bf741 to cbd1334 Compare September 13, 2024 00:01
@stephane-airbyte stephane-airbyte force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 83e2dda to 88fd78e Compare September 13, 2024 00:01
@stephane-airbyte stephane-airbyte force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from cbd1334 to 0005abc Compare September 13, 2024 00:08
@stephane-airbyte stephane-airbyte force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 88fd78e to 1601c23 Compare September 13, 2024 00:08
@stephane-airbyte stephane-airbyte force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from 0005abc to 2d22e6f Compare September 13, 2024 01:41
@stephane-airbyte stephane-airbyte force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 1601c23 to a607474 Compare September 13, 2024 01:41
@stephane-airbyte stephane-airbyte force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 25ccb81 to 45b9a08 Compare September 18, 2024 00:36
@stephane-airbyte stephane-airbyte force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from 05cc92b to 09fb99c Compare September 18, 2024 02:28
@stephane-airbyte stephane-airbyte force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 45b9a08 to 5130763 Compare September 18, 2024 02:28
@octavia-squidington-iii octavia-squidington-iii added the area/documentation Improvements or additions to documentation label Sep 18, 2024
@stephane-airbyte stephane-airbyte marked this pull request as ready for review September 18, 2024 04:00
@stephane-airbyte stephane-airbyte requested a review from a team as a September 18, 2024 04:00
@stephane-airbyte stephane-airbyte force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch 2 times, most recently from 1b5edad to d2c938a Compare September 18, 2024 18:47
@stephane-airbyte stephane-airbyte force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 5130763 to 85c5c73 Compare September 18, 2024 18:47
Copy link
Contributor

@johnny-schmidt johnny-schmidt left a comment

Choose a reason for hiding this comment

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

Makes sense
1 remove the primary key fields, totaling their size; add them to final data
2 sort the remaining by size ascending
3 keep adding them to the final data until we hit the limit, then start nulling and tracking changes

Questions:

  1. where does this limit come from 16 * 1_024 * 1_024?; does SF enforce that the string size of all the fields in a row be less than this? or is this to enforce serialization size in the raw table?
  2. is this a hard limit? if so, what happens if the PK fields are too big (obviously unlikely); also, if this is for serialization size in the raw table, won't that size be larger due to the format? do the extra meta fields come into play? could the meta itself blow up if there were lots of fields past the limit
  3. this leaves the fields sorted by size, I assume that's okay? nothing downstream is dependent on field order (including tests)?

@stephane-airbyte stephane-airbyte force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from d2c938a to dfd8fd1 Compare September 18, 2024 20:56
@stephane-airbyte stephane-airbyte force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 85c5c73 to 75c2005 Compare September 18, 2024 20:56
@stephane-airbyte stephane-airbyte changed the base branch from stephane/09-11-destination-snowflake_speed_up_metadata_queries to graphite-base/45431 September 18, 2024 22:14
@edgao
Copy link
Contributor

edgao commented Sep 18, 2024

(declining this review, unless @stephane-airbyte you want a third set of eyes here)

@stephane-airbyte stephane-airbyte force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 75c2005 to a85007e Compare September 18, 2024 22:15
@stephane-airbyte stephane-airbyte changed the base branch from graphite-base/45431 to master September 18, 2024 22:15
@stephane-airbyte stephane-airbyte force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from a85007e to 087abd9 Compare September 18, 2024 22:15
@stephane-airbyte
Copy link
Contributor Author

stephane-airbyte commented Sep 18, 2024

Makes sense 1 remove the primary key fields, totaling their size; add them to final data 2 sort the remaining by size ascending 3 keep adding them to the final data until we hit the limit, then start nulling and tracking changes

Questions:

  1. where does this limit come from 16 * 1_024 * 1_024?; does SF enforce that the string size of all the fields in a row be less than this? or is this to enforce serialization size in the raw table?

There's a weird 16MB limit that's on the VARIANT type. It's weird because it's not exact. They say it's compressed size (so raw size could be bigger), but could be smaller because of overhead...

  1. is this a hard limit? if so, what happens if the PK fields are too big (obviously unlikely); also, if this is for serialization size in the raw table, won't that size be larger due to the format? do the extra meta fields come into play? could the meta itself blow up if there were lots of fields past the limit

If the sum of PK fields is bigger than 16MB, we just try to insert the record anyways, and we'll fail then. Seemed like dying was the only right thing to do short of losing data

  1. this leaves the fields sorted by size, I assume that's okay? nothing downstream is dependent on field order (including tests)?

yeah, tests look at the json field names, they don't care about order. Neither do our T+D queries

@stephane-airbyte stephane-airbyte force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 087abd9 to 454059f Compare September 18, 2024 22:45
@stephane-airbyte stephane-airbyte merged commit ccd0ea6 into master Sep 19, 2024
34 checks passed
@stephane-airbyte stephane-airbyte deleted the stephane/09-12-destination-snowflake_truncate_large_records branch September 19, 2024 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/documentation Improvements or additions to documentation connectors/destination/snowflake
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants