Skip to content
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

log macro fails in pre/post-hook without the select 1 workaround #1108

Closed
robert-howley-zocdoc opened this issue Nov 2, 2018 · 0 comments · Fixed by #1719
Closed

log macro fails in pre/post-hook without the select 1 workaround #1108

robert-howley-zocdoc opened this issue Nov 2, 2018 · 0 comments · Fixed by #1719
Labels
bug Something isn't working

Comments

@robert-howley-zocdoc
Copy link

robert-howley-zocdoc commented Nov 2, 2018

Issue

Issue description

The log macro cause the model evaluation to fail when executed in a model level pre/post-hook unless the select 1 hack is applied.

Here is the relevant snippet from the dbt_project.yml

# no problem here
on-run-start: "{{ log('project level: pre-hook', True) }}"
on-run-end: "{{ log('project level: post-hook', True) }}"

models:
  # fails
  # pre-hook: "{{ log('models level: pre-hook', True) }}"
  # post-hook: "{{ log('models level: post-hook', True) }}"

  # works
  pre-hook: "{{ log('models level: pre-hook', True) }} select 1"
  post-hook: "{{ log('models level: post-hook', True) }} select 1"

Results

What happened?

Without the select 1 workaround I get the following ...

Found 3 operations, 91 macros, 0 analyses, 0 seed files, 0 tests, 1 models, 0 archives

project level: pre-hook
16:23:32 | Concurrency: 1 threads (target='prod')
16:23:32 | 
16:23:32 | 1 of 1 START view model experimental.my_first_dbt_model.............. [RUN]
models level: pre-hook
16:23:33 | 1 of 1 ERROR creating view model experimental.my_first_dbt_model..... [ERROR in 0.86s]
project level: post-hook
16:23:33 | 
16:23:33 | Finished running 1 view models in 1.17s.

Completed with 1 errors:

Database Error in model my_first_dbt_model (models/example/my_first_dbt_model.sql)
  can't execute an empty query
  compiled SQL at target/compiled/my_new_package/example/my_first_dbt_model.sql

Done. PASS=0 ERROR=1 SKIP=0 TOTAL=1

What did you expect to happen?

Expected the view to be successfully created with models level: pre-hook to be printed before the view creation and models level: post-hook after.

System information

The output of dbt --version:

installed version: 0.11.1
   latest version: 0.11.1

Up to date!

The operating system you're running on: mac sierra

The python version you're using (probably the output of python --version) 2.7

Steps to reproduce

Add the above dbt_project.yml snippet to the sample project autogenerated by db init and connect to redshift.

@drewbanin drewbanin added the bug Something isn't working label Sep 3, 2019
@drewbanin drewbanin added this to the Louisa May Alcott milestone Sep 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants