Issue with Post Hooks Not Running With DBT 0.16.1

I’ve noticed an issue yesterday and today where my post hooks which create my indexes are no longer running after the end of my model.

post_hook=[
‘CREATE UNIQUE INDEX IF NOT EXISTS UI_{{ this.name }}_pk_id ON {{ this }} (“pk_id”)’
]

Did something change recently where this syntax is no longer working like it did for prior versions?

Hi @chanwd
Sounds like you might be experiencing a bug. To help us understand this issue, please use this format:

Describe the bug

A clear and concise description of what the bug is. What command did you run? What happened?

Steps to reproduce

In as much detail as possible, please provide steps to reproduce the issue. Sample data that triggers the issue, example model code, etc is all very helpful here.

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots and log output

If applicable, add screenshots or log output to help explain your problem.

System information

Which database are you using dbt with?

  • [ ] postgres
  • [ ] redshift
  • [ ] bigquery
  • [ ] snowflake
  • [ ] other (specify: ____________)

The output of dbt --version:

<output goes here>

The operating system you’re using:

The output of python --version:

Additional context

Add any other context about the problem here.

HI Claire, sorry for the late response. Here is the information you’ve requested:

Describe the bug

If you attempt to recreate a model using --full-refresh, indexes that already existed on the table won’t be recreated as part of the full-refresh. If you add a new index to the model, only that index will be created, the existing indexes will not be recreated.

Steps to reproduce

  1. Create a model that contains post hooks for adding indexes if they don’t exist.

Something like this:

{{
config(
materialized=‘incremental’,
unique_key=‘id’,
post_hook=[
‘CREATE UNIQUE INDEX IF NOT EXISTS UI_{{ this.name }}id ON {{ this }} (“id”)’,
'CREATE INDEX IF NOT EXISTS IDX
{{ this.name }}survey_type_id ON {{ this }} (“survey_type_id”)’,
'CREATE INDEX IF NOT EXISTS IDX
{{ this.name }}_pulse_id ON {{ this }} (“pulse_id”)’
]
)
}}

SELECT
id,
survey_type_id,
pulse_id
FROM {{ ref(‘survey’) }}

  1. Confirm the model was created with the indexes expected. If the model didn’t exist before, it will contain all the indexes. If it’s a model that already exists with those indexes, the existing indexes won’t be recreated as part of the full-refresh.

  2. Add an index to the post hook then run dbt run --model modelName --full-refresh. Note that only the new index you added will be present but the ones that were on the model prior to the full-refresh are not recreated.

Expected behavior

My expectations are that the indexes should always be recreated as part of a full-refresh just like 0.14.0.

Screenshots and log output

No screenshots.

System information

Which database are you using dbt with?

We’re using Aurora Postgres

The output of dbt --version :

We’re using 0.16.1 on our Dev and QA enviornments. I can verify that on Production we’re using 0.14.0 and do not have these issues.

The operating system you’re using:

MAC

The output of python --version :

Python 2.7.10

Additional context

None

Hi @claire , I was wondering if you had an update on this particular bug or needed more information from me?

Thanks,
Will