Skip to content

destination-snowflake: truncate large records - #45431

Merged
Stephane Geneix (stephane-airbyte) merged 1 commit into
masterfrom
stephane/09-12-destination-snowflake_truncate_large_records
Sep 19, 2024
Merged

Stephane Geneix (stephane-airbyte) merged 1 commit into
masterfrom
stephane/09-12-destination-snowflake_truncate_large_records

Conversation

@stephane-airbyte

@stephane-airbyte Stephane Geneix (stephane-airbyte) commented Sep 12, 2024 •

Copy link
Copy Markdown
Contributor

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.

@vercel

vercel Bot commented Sep 12, 2024 •

Copy link
Copy Markdown

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 Geneix (stephane-airbyte) commented Sep 12, 2024 •

Copy link
Copy Markdown
Contributor Author

@stephane-airbyte
Stephane Geneix (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 Geneix (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 Geneix (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 Geneix (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 Geneix (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 Geneix (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 Geneix (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 Geneix (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 Geneix (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 Geneix (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 Geneix (stephane-airbyte) force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from daabc9b to b9352bf Compare September 16, 2024 20:19
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from ab4981b to 36ff551 Compare September 16, 2024 20:52
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from b9352bf to 29afc32 Compare September 16, 2024 20:52
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from 36ff551 to ef8ca17 Compare September 16, 2024 21:00
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 29afc32 to b0f2e94 Compare September 16, 2024 21:00
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from ef8ca17 to 8ceef31 Compare September 16, 2024 21:59
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from b0f2e94 to ef3275f Compare September 16, 2024 21:59
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from 8ceef31 to d9e641e Compare September 17, 2024 01:12
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from ef3275f to 55a3739 Compare September 17, 2024 01:12
@stephane-airbyte
Stephane Geneix (stephane-airbyte) changed the base branch from stephane/09-11-destination-snowflake_speed_up_metadata_queries to stephane/09-13-change_signature_of_orphanedthreadfilter September 17, 2024 01:13
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-13-change_signature_of_orphanedthreadfilter branch from 90c1a66 to c35540c Compare September 17, 2024 01:15
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 55a3739 to 442a24b Compare September 17, 2024 01:24
@stephane-airbyte
Stephane Geneix (stephane-airbyte) changed the base branch from stephane/09-13-change_signature_of_orphanedthreadfilter to stephane/09-11-destination-snowflake_speed_up_metadata_queries September 17, 2024 01:24
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from c7beaee to b07ca08 Compare September 17, 2024 18:18
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 442a24b to 4b3f6f3 Compare September 17, 2024 18:18
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from b07ca08 to e65acb4 Compare September 17, 2024 18:25
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 4b3f6f3 to da7e4ba Compare September 17, 2024 18:25
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from e65acb4 to afe55f2 Compare September 17, 2024 21:17
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from da7e4ba to 9284182 Compare September 17, 2024 21:18
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from afe55f2 to 5e9b9c1 Compare September 17, 2024 21:42
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 9284182 to 695511d Compare September 17, 2024 21:42
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from 5e9b9c1 to 1a20860 Compare September 17, 2024 21:44
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 695511d to 25ccb81 Compare September 17, 2024 21:45
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-11-destination-snowflake_speed_up_metadata_queries branch from 1a20860 to 05cc92b Compare September 18, 2024 00:35
@stephane-airbyte
Stephane Geneix (stephane-airbyte) force-pushed the stephane/09-12-destination-snowflake_truncate_large_records branch from 25ccb81 to 45b9a08 Compare September 18, 2024 00:36

Copy link
Copy Markdown
Contributor

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)?

@edgao

Copy link
Copy Markdown
Contributor

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

@stephane-airbyte

Stephane Geneix (stephane-airbyte) commented Sep 18, 2024 •

Copy link
Copy Markdown
Contributor Author

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

This branch was successfully deployed

1 active deployment
Preview — 454059f3 Deployed Sep 18, 2024 by vercel[bot]
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