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

[CT-2784] [Feature] Add macro drop_schema_named as wrapper around adapter.drop_schema #8025

Closed
3 tasks done
jtcohen6 opened this issue Jul 4, 2023 · 2 comments · Fixed by #8868
Closed
3 tasks done
Assignees
Labels
enhancement New feature or request Impact: Adapters

Comments

@jtcohen6
Copy link
Contributor

jtcohen6 commented Jul 4, 2023

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion

Describe the feature

internal slack thread for context

Create a new macro to drop schemas that can be easily called from the CLI (via run-operation), by simply passing the schema name as a string, rather than requiring the prior construction of a Relation object.

{% macro drop_schema_named(schema_name) %}
  {% set schema_relation = api.Relation.create(schema=schema_name, database="", identifier="") %}
  {{ adapter.drop_schema(schema_relation) }}
{% endmacro %}

(This should be adapter.drop_schema to take advantage of transaction handling required for some databases)

Then, it can be called from the CLI, without requiring any customization to the global project:

dbt run-operation drop_schema_named --args 'schema_name: <schema_to_drop>'

Describe alternatives you've considered

This works in v1.5+, but it feels pretty hacky:

dbt compile --inline "{{ adapter.drop_schema(api.Relation.create(schema="<schema_to_drop>", database="", identifier="")) }}"

Who will this benefit?

Deployment & orchestration tools (e.g. dbt Cloud) that need to create temporary schemas, and then wish to leverage dbt's per-adapter capabilities for dropping them

Are you interested in contributing this feature?

sure :)

Anything else?

No response

@jtcohen6 jtcohen6 added the enhancement New feature or request label Jul 4, 2023
@github-actions github-actions bot changed the title [Feature] Add macro drop_schema_named as wrapper around adapter.drop_schema [CT-2784] [Feature] Add macro drop_schema_named as wrapper around adapter.drop_schema Jul 4, 2023
@jtcohen6 jtcohen6 self-assigned this Jul 5, 2023
@graciegoheen graciegoheen added Team:Adapters Issues designated for the adapter area of the code and removed Team:Adapters Issues designated for the adapter area of the code labels Aug 21, 2023
@graciegoheen
Copy link
Contributor

Hey @nathaniel-may - flagging this, as it may affect the adapters team

@colin-rogers-dbt
Copy link
Contributor

@jtcohen6 / @graciegoheen ran into this while working on something else, raised a quick PR to add the macro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Impact: Adapters
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants