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

use show schemas for snowflake list_schemas (#2166) #2171

Merged
merged 4 commits into from
Mar 3, 2020

Conversation

beckjake
Copy link
Contributor

resolves #2166

Description

Use show terse schemas on snowflake, instead of selecting schemas from information_schema.schemata.

Checklist

  • I have signed the CLA
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR Existing tests do not break for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt next" section.

Also fix up the changelog to better reflect releases
@cla-bot cla-bot bot added the cla:yes label Feb 28, 2020
Copy link
Contributor

@drewbanin drewbanin left a comment

Choose a reason for hiding this comment

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

One comment about error handling, but otherwise this LGTM! This change, plus parallelizing the info schema queries we do make, knocks 5s of the runtime for our internal analytics project!

This was super great, I'm glad we did this. Let's also investigate making the same type of change around listing objects in a schema in a future release (#2174).

Ship it once that error handling change is addressed!

@@ -81,3 +82,13 @@ def post_model_hook(
) -> None:
if context is not None:
self._use_warehouse(context)

def list_schemas(self, database: str) -> List[str]:
results = self.execute_macro(
Copy link
Contributor

Choose a reason for hiding this comment

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

If the show schemas query fails (ie. because the database does not exist, or because the user does not have permission), the stdout looks like:

snowflake.connector.errors.ProgrammingError: 002043 (02000): SQL compilation error:
Object does not exist, or operation cannot be performed.

Can we catch this error and re-raise something more helpful, like:

Database error while listing schemas in database '<db name>'
Object does not exist, or operation cannot be performed. <---- the database error

…age about what is going on when list_schemas fails
@beckjake beckjake force-pushed the feature/use-show-schemas-snowflake branch from 6d7e453 to 47cef1d Compare March 2, 2020 03:48
Copy link
Contributor

@drewbanin drewbanin left a comment

Choose a reason for hiding this comment

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

ship it!

@beckjake beckjake merged commit f209e17 into dev/barbara-gittings Mar 3, 2020
@beckjake beckjake deleted the feature/use-show-schemas-snowflake branch March 3, 2020 04:27
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.

Use show schemas instead of selecting from information_schema.schemata on Snowflake
2 participants