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

[Feature] Paper cut: include reference to execute mode check when introspective queries like run_query are skipped #11070

Open
3 tasks done
joellabes opened this issue Nov 28, 2024 · 0 comments
Labels
enhancement New feature or request triage

Comments

@joellabes
Copy link
Contributor

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion

Describe the feature

When using functions like run_query, the if execute check is necessary to avoid failures during the parse phase. Otherwise,

Any Jinja that relies on a result being returned from the database will error during the parse phase.
The error returned by dbt will look as follows:

Encountered an error:
Compilation Error in model order_payment_methods (models/order_payment_methods.sql)
  'None' has no attribute 'table'

Let's provide information about why this happened inline. Something like this:

Running dbt...

Encountered an error:
Compilation Error in model order_payment_methods (models/order_payment_methods.sql)
  'None' has no attribute 'table'
  dbt is currently not running in execute mode. You might need to wrap this code in an `if execute` block https://docs.getdbt.com/reference/dbt-jinja-functions/execute

Describe alternatives you've considered

I don't know if we actually can update the Compilation Error message with guidance because it's too late by then, so alternatively we could also add a warning line inside of run_query and friends so you wind up with something like this:

Running dbt...

WARN: run_query was invoked in the model order_payment_methods, but dbt is currently not running in execute mode so accessing the result will fail. Wrap in an `if execute` block https://docs.getdbt.com/reference/dbt-jinja-functions/execute

Encountered an error:
Compilation Error in model order_payment_methods (models/order_payment_methods.sql)
  'None' has no attribute 'table'

Who will this benefit?

Pretty much everyone who uses introspection, including:

image

Are you interested in contributing this feature?

Maybe, if it turns out to just be "update an error message somewhere" but probably not realistically

Anything else?

No response

@joellabes joellabes added enhancement New feature or request triage labels Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage
Projects
None yet
Development

No branches or pull requests

1 participant