-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Cannot override dbt default materializations #1962
Comments
I don’t really understand how this bug happened in the sense that I have no idea what could've changed, but the current 0.15.0 behavior is that we do these searches:
Neither search specifies the package name, so we just grab the first matching macro. In 0.15.0, the way we build the macros dict is core-macros-first. So since we iterate over the dict to search, we happen to always find core first. That means in Python <3.6 where dicts are randomly sorted, the result would be non-deterministic? Which seems pretty bad, way worse than this! My reading of 0.14.4 is that it's doing the same thing (loading internal packages first, iterating in dict order), so I am honestly not sure at all what changed here - I assume in <0.15 we built the dict subtly differently during parsing and it happened to work out. My first thought was to instead add a check where we add an outer loop that includes the package name - first look in the model’s package, and then look “anywhere”. But then I realized that if there's a dependency that has a materialization macro override in it (maybe you wanted to override On a related note: it looks a lot like adapter plugins can accidentally override the default materialization. dbt should ignore that (because @drewbanin maybe these are some nice UX problems for you to ponder over thanksgiving :) For now I'm going to proceed by mostly just ignoring the dependencies problem, but I don't feel great about that. We should at least document whatever we choose (and let's not document "we chose dictionary order"!). |
I can't say that it's the right way to handle it but at Ocado we decided this morning that if we're using our own materialization (even if it's based off of a default dbt one) we should use a different name for it to make it clear that the logic is not the same regardless of whether we can override materializations or not. That may or may not help with your UX problems but I thought I'd let you know the route we decided to take. |
@beckjake I did see some hard-to-reproduce instances of dbt not picking up user-space materializations on < 0.15.0. Nondeterministic ordering with < py36 does sound like a likely (and really bad!) culprit.
I'm not certain I totally understand the failure mode here. I like the idea of an outer loop that searches by package. The order of resolution should be:
Can you clarify what the issue would be with an approach like this?
I think part of the good answer here probably includes better materialization namespacing. That might mean having to do
Cool, strong agree. Let's resolve materializations in the following order:
I have to check out how this works in practice, but my thinking here is that each macro source above will overwrite the ones above it. So, @r-hempenstall I think your approach is a good one, and I imagine it's the approach we'll want to document and recommend to avoid ambiguity/confusion for users with more complex materialization use cases. |
…lizations add a formal search order for materializations, tests (#1962)
Describe the bug
I created a customised version of the incremental materialization. I then tried to use that materialization for one of my models and it didn't work -- dbt used the default incremental materialization still. This seems to be the case with other materializations as well.
Steps To Reproduce
Create a fresh dbt project backed by BigQuery using
dbt init
. Next create a materialization to override one of the default dbt materializations; I used the one below.I then changed the default model to the following.
This would be expected to log
USING MY IMPLEMENTATION
to my terminal and then exit with an error but when I rundbt run
I get a nice log output ending withCompleted Successfully
. If I change the name of the materialization tomy_incremental
in both files then I get the log line and error message as I would expect.Expected behavior
I would expect that my materialization would be used rather than dbt's if they both have the same name. In the example above, that would give me the log line and error message that I expected.
Screenshots and log output
The output I expected when I overrode the incremental materialization.
The output I actually got.
System information
Which database are you using dbt with?
The output of
dbt --version
:The operating system you're using: macOS Mojave
The output of
python --version
: Python 3.6.8The text was updated successfully, but these errors were encountered: