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

Restore drop_schema to adapter in jinja context (#1980) #1983

Merged
merged 2 commits into from
Dec 5, 2019

Conversation

beckjake
Copy link
Contributor

@beckjake beckjake commented Dec 5, 2019

Fixes #1980

I can't remember if we removed this as an adapter method intentionally or accidentally, but it was a mistake either way.

As part of this I fixed up the cache's behavior when you do things to schemas (dropping a schema now cascades into dropping all its contents, as it should). There was an especially tricky bug with renaming relations where we effectively dropped the old relation's schema(!!!)

I added a test, it is basically a big pile of things you should never do, but it tests this functionality well enough. I made the test for each db as this seems like something easy to break on a per-db basis.

Made a few related fixes to caching behavior w.r.t schemas
Added a test
@cla-bot cla-bot bot added the cla:yes label Dec 5, 2019
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 worth discussing here, but this overall looks really good. The new tests are great :)

self.execute_macro(DROP_SCHEMA_MACRO_NAME,
kwargs=kwargs)
self.execute_macro(DROP_SCHEMA_MACRO_NAME, kwargs=kwargs)
self.commit_if_has_connection()
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to commit here? I'm not sure a consumer of this method would expect a commit to occur, and I can imagine this being dangerous for certain uses!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought we did because the create schema also commits. I sort of assumed they both should, I'll revert it.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, create_schema should probably not commit - these sprinkled-in transactional statements make it super hard to reason about what dbt is doing in different parts of the codebase.

I do think that committing a create schema feels "safer" than committing the drop - it's the destructive nature of this method that gave me pause. Reverting it sounds good to me -- ship it when the tests pass!

@beckjake beckjake merged commit d14d250 into dev/0.15.1 Dec 5, 2019
@beckjake beckjake deleted the fix/restore-drop-schema branch December 5, 2019 23:45
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.

compilation error on adapter.drop_schema: no attribute 'drop_schema'
2 participants