As a test I’ve copied an existing incremental materialisation from github:
to the macros folder in my dbt project.
I’ve Renamed the materialisation from incremental to incrementalx
{% materialization incremental, default -%}
to:
{% materialization incrementalx, default -%}
And used this in a model that is set to use incremental materialisation in the model’s config block:
The standard incremental materialisation worked fine, the incrementalx materialisation (only a copy from git and a rename) did not, for some reason it used the select statement that was inside the
else part (so the initial load part) and used this as a basis for the merge (and that failed).
When switching the materialisation back from incrementalx to incremental the correct incremental select was used and the merge statement completed as expected.
The context of why I’m trying to do this
In order to create a custom incremental strategy whilst not altering existing functionality.
What I’ve already tried
Described above, i wanted to make sure that everything worked as expected, i wanted to use the existing materialisation as a base (since that works and i only need a small tweak)
Some example code or error messages
Described above, the incorrect select statement was used as a tmp table.
Put code inside backticks
to preserve indentation
which is especially important
for Python and YAML!
I assume that I can place a copy in my macros folder and that I should keep the macro name is_incremental (overloading) so it gets “picked up” by dbt, the difference would be to change:
model.config.materialized == ‘incrementalx’ and everything works as expected.
If I want to keep this “seperate” (not to interfere with existing incremental) I can’t just rename the macro as well to lets say incrementalx since dbt doesnt know that this needs to be used instead of the original incremental in the case of an incrementalx materialized model?