[CT-2776] [Feature] Allow get_metadata_vars()
to populate from env post-initial invocation
#8010
Closed
3 tasks done
Labels
enhancement
New feature or request
help_wanted
Trickier changes, with a clear starting point, good for previous/experienced contributors
logging
Is this your first time submitting a feature request?
Describe the feature
The requested feature from this change enables
get_metadata_vars()
to be populated if the environment is updated after the first timeget_metadata_vars()
is ever called.Impetus is that in our deployments, we need to inject the project
vars
into thedata.extra
attribute of each Log Line to operate on for alerting down to the team / project / environment - mechanically, this means:DBT_ENV_CUSTOM_ENV_
and jam them into the runtime environmentbuild
command so that the custom env vars make it intodata.extra
attribute of log lines it emitsExample
Post applying #7998, the following is possible:
More context
When using programmatic invocations, the
dbt.core.events.functions.get_metadata_vars()
function is called once when thedbtRunner
is instantiated.If no
DBT_ENV_CUSTOM_ENV_*
vars are found the first time it's called, it will continue to return an empty Dictionary upon subsequent invocations and will miss environment variables added after its initial instantiation.The main consideration is if there are any ramifications from checking the environment each time
get_metadata_vars()
is called until it (possibly) becomes populated - this should only be a concern ifget_metadata_vars()
is called a zillion times and too costly to re-calculate on the fly.Describe alternatives you've considered
Trying to get these project vars into the runtime environment before initial instantiation (untenable, we use project
vars
too heavily)Who will this benefit?
Those using programmatic invocations and wanting to update the runtime environment across invocations of
dbtRunner.invoke()
.Are you interested in contributing this feature?
Here is a link to the required change that has been tested locally.
The text was updated successfully, but these errors were encountered: