dbt-labs / dbt-adapters

Apache License 2.0
28 stars 38 forks source link

[Bug] Behavior flags should take the default value when the project file is not loaded #338

Closed mikealfare closed 4 weeks ago

mikealfare commented 1 month ago

Problem

We don't always get the flags property on the config object that gets used to create a BaseAdapter instance. This happens whenever project.yml is not loaded. In particular, this happens during dbt debug, which is meant to be a quick check of whether we can connect to a database; this command only requires profile.yml.

The decision was initially made to not load any behavior flags in the scenarios where project.yml was not loaded. The rationale there was that we did not want to return one value for a behavior flag when project.yml is not loaded (hence the default) and another value for the behavior flag when project.yml is loaded (the default, potentially overridden by the user). However, in the former scenario, referencing the behavior flag at all results in a CompilationError since the flag does not exist on BaseAdapter.behavior. This is not desirable behavior either.

Solution

While the behavior flags are loaded onto BaseAdapter.behavior dynamically, the object should always have the same flags available. Since the user's overrides are not available when project.yml is not loaded, we should act as if project.yml was loaded, but without a flags node. In other words, we should simply assume the default values when we don't get a flags attribute.

Checklist

github-actions[bot] commented 1 month ago

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.