Skip to content

🐛Destination-Snowflake: Added "Table/Stage already exists, but no permissions" handler on Sync action #21912

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

Merged

Conversation

etsybaev
Copy link
Contributor

@etsybaev etsybaev commented Jan 26, 2023

What

Users may try to write to the same destination from different connectors. In this case, we may get a "Table/Stage already exists, but no permissions" error msg.

How

Added handlers to capture it and report it as a config error

🚨 User Impact 🚨

No breaking changes expected

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/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.

@etsybaev etsybaev temporarily deployed to more-secrets January 26, 2023 12:36 — with GitHub Actions Inactive
@etsybaev etsybaev temporarily deployed to more-secrets January 26, 2023 12:36 — with GitHub Actions Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Jan 26, 2023

Affected Connector Report

NOTE ⚠️ Changes in this PR affect the following connectors. Make sure to do the following as needed:

  • Run integration tests
  • Bump connector or module version
  • Add changelog
  • Publish the new version

✅ Sources (0)

Connector Version Changelog Publish
  • See "Actionable Items" below for how to resolve warnings and errors.

❌ Destinations (21)

Connector Version Changelog Publish
destination-azure-blob-storage 0.1.6
destination-clickhouse 0.2.2
(changelog missing)
destination-clickhouse-strict-encrypt 0.2.2 🔵
(ignored)
🔵
(ignored)
destination-databricks 0.3.1
destination-dynamodb 0.1.7
destination-gcs 0.2.14
destination-mariadb-columnstore 0.1.7
destination-mssql 0.1.22
destination-mssql-strict-encrypt 0.1.22 🔵
(ignored)
🔵
(ignored)
destination-mysql 0.1.20
destination-mysql-strict-encrypt 0.1.21
(mismatch: 0.1.20)
🔵
(ignored)
🔵
(ignored)
destination-oracle 0.1.19
destination-oracle-strict-encrypt 0.1.19 🔵
(ignored)
🔵
(ignored)
destination-postgres 0.3.26
destination-postgres-strict-encrypt 0.3.26 🔵
(ignored)
🔵
(ignored)
destination-redshift 0.3.56
destination-rockset 0.1.4
destination-snowflake 0.4.47
destination-teradata 0.1.0
destination-tidb 0.1.0
destination-yugabytedb 0.1.0
  • See "Actionable Items" below for how to resolve warnings and errors.

👀 Other Modules (1)

  • base-normalization

Actionable Items

(click to expand)

Category Status Actionable Item
Version
mismatch
The version of the connector is different from its normal variant. Please bump the version of the connector.

doc not found
The connector does not seem to have a documentation file. This can be normal (e.g. basic connector like source-jdbc is not published or documented). Please double-check to make sure that it is not a bug.
Changelog
doc not found
The connector does not seem to have a documentation file. This can be normal (e.g. basic connector like source-jdbc is not published or documented). Please double-check to make sure that it is not a bug.

changelog missing
There is no chnagelog for the current version of the connector. If you are the author of the current version, please add a changelog.
Publish
not in seed
The connector is not in the seed file (e.g. source_definitions.yaml), so its publication status cannot be checked. This can be normal (e.g. some connectors are cloud-specific, and only listed in the cloud seed file). Please double-check to make sure that it is not a bug.

diff seed version
The connector exists in the seed file, but the latest version is not listed there. This usually means that the latest version is not published. Please use the /publish command to publish the latest version.

@etsybaev
Copy link
Contributor Author

etsybaev commented Jan 26, 2023

/test connector=connectors/destination-snowflake

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

Name                                                              Stmts   Miss  Cover
-------------------------------------------------------------------------------------
normalization/transform_config/__init__.py                            2      0   100%
normalization/transform_catalog/reserved_keywords.py                 14      0   100%
normalization/transform_catalog/__init__.py                           2      0   100%
normalization/destination_type.py                                    14      0   100%
normalization/__init__.py                                             4      0   100%
normalization/transform_catalog/destination_name_transformer.py     166      8    95%
normalization/transform_catalog/table_name_registry.py              174     34    80%
normalization/transform_config/transform.py                         189     48    75%
normalization/transform_catalog/utils.py                             51     14    73%
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                 595    400    33%
-------------------------------------------------------------------------------------
TOTAL                                                              1441    629    56%

Build Passed

Test summary info:

All Passed

@etsybaev etsybaev temporarily deployed to more-secrets January 26, 2023 12:43 — with GitHub Actions Inactive
@etsybaev etsybaev temporarily deployed to more-secrets January 26, 2023 12:43 — with GitHub Actions Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Jan 26, 2023

Airbyte Code Coverage

There is no coverage information present for the Files changed

Total Project Coverage 24.04%

@etsybaev etsybaev marked this pull request as ready for review January 26, 2023 13:17
@etsybaev etsybaev requested a review from a team as a code owner January 26, 2023 13:18
@@ -67,7 +67,11 @@ protected Optional<ConfigErrorException> checkForKnownConfigExceptions(Exception

@Override
public void createTableIfNotExists(final JdbcDatabase database, final String schemaName, final String tableName) throws SQLException {
database.execute(createTableQuery(database, schemaName, tableName));
try{
Copy link
Contributor

@grishick grishick Jan 26, 2023

Choose a reason for hiding this comment

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

nit: add space before {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated, thanks

Copy link
Contributor

@grishick grishick left a comment

Choose a reason for hiding this comment

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

LGTM except for one missing space between try and {. Don't forget to publish a new version of Snowflake destination before merging.

@etsybaev etsybaev temporarily deployed to more-secrets January 26, 2023 18:50 — with GitHub Actions Inactive
@etsybaev etsybaev temporarily deployed to more-secrets January 26, 2023 18:50 — with GitHub Actions Inactive
@octavia-squidington-iv octavia-squidington-iv added the area/documentation Improvements or additions to documentation label Jan 26, 2023
@grishick
Copy link
Contributor

Also, let's wait for this PR to merge (since it is already publishing): #20631 and then rebase this PR before publishing

@etsybaev etsybaev temporarily deployed to more-secrets January 26, 2023 19:02 — with GitHub Actions Inactive
@etsybaev etsybaev temporarily deployed to more-secrets January 26, 2023 19:02 — with GitHub Actions Inactive
@@ -20,5 +20,5 @@ RUN tar xf ${APPLICATION}.tar --strip-components=1

ENV ENABLE_SENTRY true

LABEL io.airbyte.version=0.4.45
LABEL io.airbyte.version=0.4.46
Copy link
Contributor

Choose a reason for hiding this comment

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

this will change after this PR is merged: #20631

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup, thanks. I'd bumped the version and after pushing noticed your comment to wait for another PR. It was 1 minute earlier :)

Assertions.assertInstanceOf(ConfigErrorException.class, exception);
} else {
Assertions.assertInstanceOf(SnowflakeSQLException.class, exception);
Assertions.assertEquals(exception.getMessage(), message);
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit: you probably don't need to explicitly define Assertions.assertEquals since at the top of the imports we import

import static org.junit.jupiter.api.Assertions.assertEquals;

Likely you can also do the same thing with assertInstanceOf

public void testCreateTableIfNotExists(final String message, final boolean shouldCapture) {
final JdbcDatabase db = Mockito.mock(JdbcDatabase.class);
final var schemaName = "foo";
final var tableName = "bar";
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit: since we know these values in the createTableIfNotExists takes in String values to also just have the test reflect that. It shouldn't be necessary that the tests are using type inferences when the method defines the type explicitly

Copy link
Contributor

@ryankfu ryankfu left a comment

Choose a reason for hiding this comment

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

Non-blocking nits but as Greg mentioned to wait on the publication and merging of the checkpointing changes in #20631. I can ping you once the publication is done although it might take some time since destination-snowflake takes close to 4 hours to complete the integration tests

…sts-handlers

# Conflicts:
#	docs/integrations/destinations/snowflake.md
@etsybaev
Copy link
Contributor Author

etsybaev commented Jan 30, 2023

/test connector=connectors/destination-snowflake

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

Name                                                              Stmts   Miss  Cover
-------------------------------------------------------------------------------------
normalization/transform_config/__init__.py                            2      0   100%
normalization/transform_catalog/reserved_keywords.py                 14      0   100%
normalization/transform_catalog/__init__.py                           2      0   100%
normalization/destination_type.py                                    14      0   100%
normalization/__init__.py                                             4      0   100%
normalization/transform_catalog/destination_name_transformer.py     166      8    95%
normalization/transform_catalog/table_name_registry.py              174     34    80%
normalization/transform_config/transform.py                         189     48    75%
normalization/transform_catalog/utils.py                             51     14    73%
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                 595    400    33%
-------------------------------------------------------------------------------------
TOTAL                                                              1441    629    56%

Build Passed

Test summary info:

All Passed

@etsybaev etsybaev temporarily deployed to more-secrets January 30, 2023 11:19 — with GitHub Actions Inactive
@etsybaev etsybaev temporarily deployed to more-secrets January 30, 2023 11:19 — with GitHub Actions Inactive
@etsybaev etsybaev temporarily deployed to more-secrets January 30, 2023 13:55 — with GitHub Actions Inactive
@etsybaev etsybaev temporarily deployed to more-secrets January 30, 2023 13:55 — with GitHub Actions Inactive
@etsybaev
Copy link
Contributor Author

etsybaev commented Jan 30, 2023

/publish connector=connectors/destination-snowflake

🕑 Publishing the following connectors:
connectors/destination-snowflake
https://github.com/airbytehq/airbyte/actions/runs/4044794197


Connector Did it publish? Were definitions generated?
connectors/destination-snowflake

if you have connectors that successfully published but failed definition generation, follow step 4 here ▶️

@github-actions
Copy link
Contributor

github-actions bot commented Jan 30, 2023

Platform Test Results

   234 files  ±0     234 suites  ±0   24m 54s ⏱️ - 2m 10s
1 617 tests ±0  1 606 ✔️ ±0  11 💤 ±0  0 ±0 
1 636 runs  ±0  1 625 ✔️ ±0  11 💤 ±0  0 ±0 

Results for commit 58d79eb. ± Comparison against base commit 63064d9.

♻️ This comment has been updated with latest results.

@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets January 30, 2023 15:50 — with GitHub Actions Inactive
@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets January 30, 2023 15:50 — with GitHub Actions Inactive
@etsybaev etsybaev enabled auto-merge (squash) January 30, 2023 15:56
@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets January 30, 2023 16:58 — with GitHub Actions Inactive
@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets January 30, 2023 16:58 — with GitHub Actions Inactive
@etsybaev etsybaev merged commit 9d6fe68 into master Jan 30, 2023
@etsybaev etsybaev deleted the etsybaev/20692-snowflake-added-already-exists-handlers branch January 30, 2023 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If raw table exists and destination cannot write to it - report config error
5 participants