Skip to content

Snowflake Destination apply buffering strategy on GCS staging - #12952

Merged
VitaliiMaltsev merged 11 commits into
masterfrom
vmaltsev/11428-dest-snowflake-gcs-apply-buffering
Jun 1, 2022
Merged

Snowflake Destination apply buffering strategy on GCS staging#12952
VitaliiMaltsev merged 11 commits into
masterfrom
vmaltsev/11428-dest-snowflake-gcs-apply-buffering

Conversation

@VitaliiMaltsev

@VitaliiMaltsev VitaliiMaltsev commented May 18, 2022

Copy link
Copy Markdown
Contributor

What

Follow buffering strategy (compressed serialized records) for Destination Snowflake GCS staging

How

This PR switches the Snowflake destination and stop using the SnowflakeCopyGcsDestination, but use a new SnowflakeGCSStagingDestination

So this PR simply requires its own set of StagingOperations using GCS buckets

Recommended reading order

  1. SnowflakeGCSStagingDestination.java
  2. SnowflakeGcsStagingSqlOperations.java

🚨 User Impact 🚨

Potentially a bit slower sync but more consistent memory and thread consumption thanks to on-disk buffering before staging. (More resilient to OOM and network failures)

Pre-merge Checklist

Expand the relevant checklist and delete the others.

New Connector

Community member or Airbyter

  • Community member? Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • docs/SUMMARY.md
    • docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
    • docs/integrations/README.md
    • airbyte-integrations/builds.md
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the connector is published, connector added to connector index as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here
Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub and connector version bumped by running the /publish command described here
Connector Generator
  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • If adding a new generator, add it to the list of scaffold modules being tested
  • The generator test modules (all connectors with -scaffold in their name) have been updated with the latest scaffold by running ./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates then checking in your changes
  • Documentation which references the generator is updated as needed

Tests

Unit

Put your unit tests output here.

Integration

Put your integration tests output here.

Acceptance

Put your acceptance tests output here.

@github-actions github-actions Bot added the area/connectors Connector related issues label May 18, 2022
@github-actions github-actions Bot added the area/documentation Improvements or additions to documentation label May 18, 2022
@VitaliiMaltsev

VitaliiMaltsev commented May 19, 2022

Copy link
Copy Markdown
Contributor Author

/test connector=connectors/destination-snowflake

🕑 connectors/destination-snowflake https://github.com/airbytehq/airbyte/actions/runs/2350597498
❌ connectors/destination-snowflake https://github.com/airbytehq/airbyte/actions/runs/2350597498
🐛 https://gradle.com/s/274ccjxnh2gqy

@yurii-bidiuk

Copy link
Copy Markdown
Contributor

Looks good to me! Let's fix a test and proceed with PR

@VitaliiMaltsev

VitaliiMaltsev commented May 20, 2022

Copy link
Copy Markdown
Contributor Author

/test connector=connectors/destination-snowflake

🕑 connectors/destination-snowflake https://github.com/airbytehq/airbyte/actions/runs/2357594345
✅ connectors/destination-snowflake https://github.com/airbytehq/airbyte/actions/runs/2357594345
Python tests coverage:

Name                                                              Stmts   Miss  Cover
-------------------------------------------------------------------------------------
normalization/transform_config/__init__.py                            2      0   100%
normalization/transform_catalog/reserved_keywords.py                 13      0   100%
normalization/transform_catalog/__init__.py                           2      0   100%
normalization/destination_type.py                                    13      0   100%
normalization/__init__.py                                             4      0   100%
normalization/transform_catalog/destination_name_transformer.py     155      8    95%
normalization/transform_config/transform.py                         159     31    81%
normalization/transform_catalog/table_name_registry.py              174     34    80%
normalization/transform_catalog/utils.py                             34      7    79%
normalization/transform_catalog/dbt_macro.py                         22      7    68%
normalization/transform_catalog/catalog_processor.py                147     80    46%
normalization/transform_catalog/transform.py                         61     38    38%
normalization/transform_catalog/stream_processor.py                 534    345    35%
-------------------------------------------------------------------------------------
TOTAL                                                              1320    550    58%

…ffering

# Conflicts:
#	docs/integrations/destinations/snowflake.md
@VitaliiMaltsev
VitaliiMaltsev marked this pull request as ready for review May 25, 2022 07:53

@grishick Greg Solovyev (grishick) left a comment

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.

This PR does not compile. CI shows the following build failures and I am seeing the same compilation errors when I check out these changes. Are there more changes to more files that should be included in this PR?
> Task :airbyte-integrations:connectors:destination-snowflake:compileJava FAILED /actions-runner/_work/airbyte/airbyte/airbyte-integrations/connectors/destination-snowflake/src/main/java/io/airbyte/integrations/destination/snowflake/SnowflakeGCSStagingDestination.java:57: error: incompatible types: try-with-resources not applicable to variable type try (final JdbcDatabase database = getDatabase(config)) { ^ (JdbcDatabase cannot be converted to AutoCloseable) /actions-runner/_work/airbyte/airbyte/airbyte-integrations/connectors/destination-snowflake/src/main/java/io/airbyte/integrations/destination/snowflake/SnowflakeGCSStagingDestination.java:92: error: method does not override or implement a method from a supertype @Override ^ /actions-runner/_work/airbyte/airbyte/airbyte-integrations/connectors/destination-snowflake/src/main/java/io/airbyte/integrations/destination/snowflake/SnowflakeGCSStagingDestination.java:94: error: incompatible types: JsonNode cannot be converted to DataSource return SnowflakeDatabase.getDatabase(config); ^

…ffering

# Conflicts:
#	docs/integrations/destinations/snowflake.md
@VitaliiMaltsev

Copy link
Copy Markdown
Contributor Author

This PR does not compile. CI shows the following build failures and I am seeing the same compilation errors when I check out these changes. Are there more changes to more files that should be included in this PR? > Task :airbyte-integrations:connectors:destination-snowflake:compileJava FAILED /actions-runner/_work/airbyte/airbyte/airbyte-integrations/connectors/destination-snowflake/src/main/java/io/airbyte/integrations/destination/snowflake/SnowflakeGCSStagingDestination.java:57: error: incompatible types: try-with-resources not applicable to variable type try (final JdbcDatabase database = getDatabase(config)) { ^ (JdbcDatabase cannot be converted to AutoCloseable) /actions-runner/_work/airbyte/airbyte/airbyte-integrations/connectors/destination-snowflake/src/main/java/io/airbyte/integrations/destination/snowflake/SnowflakeGCSStagingDestination.java:92: error: method does not override or implement a method from a supertype @Override ^ /actions-runner/_work/airbyte/airbyte/airbyte-integrations/connectors/destination-snowflake/src/main/java/io/airbyte/integrations/destination/snowflake/SnowflakeGCSStagingDestination.java:94: error: incompatible types: JsonNode cannot be converted to DataSource return SnowflakeDatabase.getDatabase(config); ^

fixed

@grishick

Copy link
Copy Markdown
Contributor

Hm... looks like CI tests maybe timing out.

@grishick

Greg Solovyev (grishick) commented May 25, 2022

Copy link
Copy Markdown
Contributor

/test connector=connectors/destination-snowflake

🕑 connectors/destination-snowflake https://github.com/airbytehq/airbyte/actions/runs/2387767353
❌ connectors/destination-snowflake https://github.com/airbytehq/airbyte/actions/runs/2387767353
🐛 https://gradle.com/s/2pcktgxgcywic

Build Failed

Test summary info:

Could not find result summary

@tuliren Liren Tu (tuliren) left a comment

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.

Looks good in general.

One issue is that the new implementation has lots of similar code as SnowflakeS3StagingDestination and S3StorageOperations. Ideally we would merge the shared code if possible. But this can be a separate issue.

Can you run Java formatting before merging and commit the formatting updates related to the classes in this PR? The command is: ./gradlew :spotlessJavaApply

@grishick

Greg Solovyev (grishick) commented May 27, 2022

Copy link
Copy Markdown
Contributor

After this change SnowflakeCopyGcsDestination will have no references to it in the rest of the code base, so I think this change should also delete SnowflakeCopyGcsDestination to avoid leaving behind dead code.

@VitaliiMaltsev

Copy link
Copy Markdown
Contributor Author

SnowflakeCopyGcsDestination

removed SnowflakeCopyGcsDestination class

…ffering

# Conflicts:
#	airbyte-integrations/connectors/destination-snowflake/src/main/java/io/airbyte/integrations/destination/snowflake/SnowflakeCopyGcsDestination.java
@VitaliiMaltsev

VitaliiMaltsev commented May 30, 2022

Copy link
Copy Markdown
Contributor Author

/publish connector=connectors/destination-snowflake

🕑 connectors/destination-snowflake https://github.com/airbytehq/airbyte/actions/runs/2409227308
🚀 Successfully published connectors/destination-snowflake
🚀 Auto-bumped version for connectors/destination-snowflake
✅ connectors/destination-snowflake https://github.com/airbytehq/airbyte/actions/runs/2409227308

@octavia-squidington-iii
Octavia Squidington III (octavia-squidington-iii) temporarily deployed to more-secrets May 30, 2022 14:06 Inactive
@VitaliiMaltsev

Copy link
Copy Markdown
Contributor Author

One issue is that the new implementation has lots of similar code as SnowflakeS3StagingDestination and S3StorageOperations. Ideally we would merge the shared code if possible. But this can be a separate issue.

Liren Tu (@tuliren) created separate issue https://github.com/airbytehq/airbyte-internal-issues/issues/650 because It is better to start working on it after https://github.com/airbytehq/airbyte-internal-issues/issues/501 to cover the Azure blob storage implementation as well

@VitaliiMaltsev

Copy link
Copy Markdown
Contributor Author

Greg Solovyev (@grishick) could you please approve this PR cause merging is blocked currently

@grishick

Greg Solovyev (grishick) commented Jun 1, 2022

Copy link
Copy Markdown
Contributor

/test connector=connectors/destination-snowflake

🕑 connectors/destination-snowflake https://github.com/airbytehq/airbyte/actions/runs/2418754117
✅ connectors/destination-snowflake https://github.com/airbytehq/airbyte/actions/runs/2418754117
Python tests coverage:

Name                                                              Stmts   Miss  Cover
-------------------------------------------------------------------------------------
normalization/transform_config/__init__.py                            2      0   100%
normalization/transform_catalog/reserved_keywords.py                 13      0   100%
normalization/transform_catalog/__init__.py                           2      0   100%
normalization/destination_type.py                                    13      0   100%
normalization/__init__.py                                             4      0   100%
normalization/transform_catalog/destination_name_transformer.py     155      8    95%
normalization/transform_config/transform.py                         159     31    81%
normalization/transform_catalog/table_name_registry.py              174     34    80%
normalization/transform_catalog/utils.py                             38      9    76%
normalization/transform_catalog/dbt_macro.py                         22      7    68%
normalization/transform_catalog/catalog_processor.py                147     80    46%
normalization/transform_catalog/transform.py                         61     38    38%
normalization/transform_catalog/stream_processor.py                 543    352    35%
-------------------------------------------------------------------------------------
TOTAL                                                              1333    559    58%

Build Passed

Test summary info:

All Passed

@VitaliiMaltsev
VitaliiMaltsev merged commit 748291b into master Jun 1, 2022
@VitaliiMaltsev
VitaliiMaltsev deleted the vmaltsev/11428-dest-snowflake-gcs-apply-buffering branch June 1, 2022 07:28
Jordan Scott (jscottpolevault) pushed a commit to jscottpolevault/airbyte that referenced this pull request Jun 1, 2022
…ehq#12952)

* Destination Snowflake apply buffering strategy for GCS

* Snowflake Destination apply buffering strategy on GCS staging

* updated CHANGELOG

* fixed checkstyle

* fixed compile error

* refactoring

* bump version

* auto-bump connector version

Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apply buffering changes to Snowflake Destination using GCS staging

5 participants