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

[Feature] Enable user to provide custom adapter via profiles.yml #261

Conversation

ismailsimsek
Copy link

@ismailsimsek ismailsimsek commented Jul 9, 2024

resolves dbt-labs/dbt-core#3962

Problem

Currently customizing dbt adapters and dbt functionalities is very hard to not possible. This PR enables end user to extend exsting adapters and add his/her own customization(special needs) to to it

Solution

Enabling end user to provide his/her custom adapter, using the adapter_class setting in profiles.yml

snowflake:
  target: dev
  outputs:
    dev:
      type: snowflake
      adapter_class: my.customized.adapter.SnowflakeAdapterV2Customized

and user adapter could be something like

class SnowflakeAdapterV2Customized(SnowflakeAdapter):
    def __init__(self, config) -> None:
        print(f"WARNING: Using User Provided DBT Adapter: {type(self).__module__}.{type(self).__name__}")
        super().__init__(config=config)

    @available
    def my_custom_method(self, arg1: str, arg2: str):
        print('do something here')

Checklist

  • I have read the contributing guide and understand what's expected of me
  • 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
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX

@ismailsimsek ismailsimsek requested a review from a team as a code owner July 9, 2024 12:12
Copy link

cla-bot bot commented Jul 9, 2024

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Ismail Simsek.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

Copy link

github-actions bot commented Jul 9, 2024

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@ismailsimsek
Copy link
Author

cc @jtcohen6 could you please have look? I believe the changes gives the idea. if it looks good then i will ad test as well

@ismailsimsek ismailsimsek force-pushed the enable-user-provided-custom-adapter branch from 043a3e4 to f5aba7d Compare July 9, 2024 12:16
Copy link

cla-bot bot commented Jul 9, 2024

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, please reach out through a comment on this PR.

CLA has not been signed by users: @ismailsimsek

@dbeatty10
Copy link
Contributor

Like @jtcohen6 explained in dbt-labs/dbt-core#3962 (comment), it's been a deliberate decision to not allow user-space Python code within your dbt project. We see this as serving as an important security and complexity safeguard, and we do not plan to change it. So I'm closing this PR accordingly.

@dbeatty10 dbeatty10 closed this Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overriding/Extending default adapters in dbt project
2 participants