hallowed-dog-79615
01/05/2023, 1:28 PMgenerate_database_name, so the name is dynamically generated according to some env parameters. I have used it with my models with no problem. Basically, in my models config I specify some key in the database field of the yaml, then that key is translated by the generate_database_name macro. I don't have to specifically call the macro, as it is called by default by dbt (i.e. if I specify 'shop' in the database field of a model, my macro automatically translates it to 'shop_pre' or 'shop_prod' depending on the environment).
This is not happening with sources. If I specify 'shop' as the database of a source, then the connector fails to find the 'shop' database in my warehouse. This is normal, as 'shop' does not exist, is just the key I use to then generate the real name of databases (in the example, the real databases are shop_pre and shop_prod again). From this, I infer that sources are not calling generate_database_name macro by default, but they are just taking the value in the corresponding YAML field, or calling a different macro. Is there a macro then that I can tweak in order to change this? I know that I can put simple jinja in the YAML, so I should be able to add a simple 'shop_pre' if target.name == 'pre' else 'shop_prod' , but I think its less clean than having a macro, and it is also less maintainable in the long term. Also I cannot call custom macros inside the YAML, as I will get a non defined error.
So, basically, may I change any dbt default macro that is generating the database name for sources? Maybe the source macro itself? If so, where can I find its original code of it, just to be sure I don't break it?