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 :)
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-hookAs 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 :)