dbt-labs / docs.getdbt.com

The code behind docs.getdbt.com
https://docs.getdbt.com/
Apache License 2.0
115 stars 898 forks source link

[Feature] - User Defined Macros & Filters #4872

Open afranzi opened 6 months ago

afranzi commented 6 months ago

Contributions

Link to the page on docs.getdbt.com requiring updates

Not sure if this would be part of the https://docs.getdbt.com/reference/project-configs/macro-paths Or in https://docs.getdbt.com/reference/dbt-jinja-functions

What part(s) of the page would you like to see updated?

The main idea would be adding documentation about the new incoming feature allowing DBT developers to inject their own python JINJA macros and filters in addition to the native ones, so developers can move complex jinja templating code to python and level up their dbt projects with more possibilities.

Some examples:

We can enable this behavior by defining the following ENV vars with the path:instance format.

Additional information

This documentation would be based on this PR https://github.com/dbt-labs/dbt-common/pull/72.

See following example about how I've used it locally:

Screenshot 2024-02-08 at 11 12 05 Screenshot 2024-02-08 at 11 11 36 Screenshot 2024-02-08 at 11 11 14

afranzi commented 6 months ago

Adding some examples about the credentials: Screenshot 2024-02-08 at 11 51 31 Screenshot 2024-02-08 at 11 51 38 Screenshot 2024-02-08 at 11 52 08

ismailsimsek commented 1 month ago

created related discussion here https://github.com/dbt-labs/dbt-adapters/discussions/259

IMO Adapter factory should allow user provided customized adapter class. this will open door to customization

ismailsimsek commented 1 month ago

PR https://github.com/dbt-labs/dbt-adapters/pull/261 implemented in this package https://github.com/memiiso/opendbt example https://github.com/memiiso/opendbt/blob/main/docs/EXAMPLES.md#execute-python-model-locally

using @available decorator makes the function available to jinja