Skip to content

hooks with multiple results stop execution after first result #80

@dubravcik

Description

@dubravcik

Hi, I noticed that if a hook contains multiple commands which are returning results, dbt stops execution once it gets the first result. It sometimes happens also when SQL returns some intermediate messages (like rowcount).

To reproduce it I created a useless script just to show that the execution stops right after EXEC sp_who2 and the following steps are not executed. It stops few milliseconds after first EXEC, that's why I added the WAITFOR DELAY.

{{
  config(   
    pre_hook = " 
       EXEC('DROP VIEW IF EXISTS test_bug_view')    
        
       EXEC sp_who2 -- this returns a result and execution of the hook stops

       WAITFOR DELAY '00:00:04';
       EXEC('CREATE VIEW test_bug_view AS SELECT 1 as col')
       "
  )
}}
SELECT * FROM test_bug_view --this fails, because it wasn't created in the pre-hook

As a workaround, now I make sure that there are no intermediate results and it works. For example in EXEC using NO_OUTPUT

I'd be grateful if somebody can fix it :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions