dbt-labs / dbt-utils

Utility functions for dbt projects.
https://hub.getdbt.com/dbt-labs/dbt_utils/latest/
Apache License 2.0
1.34k stars 491 forks source link

Missing column specification when using `expression_is_true` test (snowflake) #822

Closed Nic3Guy closed 7 months ago

Nic3Guy commented 1 year ago

Describe the bug

In Snowflake when I try to use the test dbt_utils.expression_is_true I get Database Error: SQL compilation error of Missing column specification

Steps to reproduce

Set up the test under the column you would like and execute `dbt test -s

Expected results

The test should compile and run

Actual results

The test is being compiled but is not running due to the compilation error in the database (in this case Snowflake)

Screenshots and log output

Screenshot 2023-08-07 154513 Screenshot 2023-08-07 154347 the compiled test: Screenshot 2023-08-07 155343

System information

The contents of your packages.yml file:

packages:
  - package: calogica/dbt_expectations
    version: [">=0.9.0", "<0.10.0"]
  - package: dbt-labs/codegen
    version: 0.10.0
  - package: elementary-data/elementary
    version: 0.9.0

Which database are you using dbt with?

The output of dbt --version:

Core:
  - installed: 1.5.0
  - latest:    1.6.0 - Update available!

  Your version of dbt-core is out of date!
  You can find instructions for upgrading here:
  https://docs.getdbt.com/docs/installation

Plugins:
  - snowflake: 1.5.0 - Update available

Additional context

When I created the same test from the source code but added a column alias like this it works as expected: image

{% test expression_is_true(model, expression, column_name=None) %}
    select
        1 as col
    from {{ model }}
    {% if column_name is none %}
        where not({{ expression }})
    {%- else %}
        where not({{ column_name }} {{ expression }})
    {%- endif %}
{% endtest %}

Are you interested in contributing the fix?

Maybe why not 👍🏼

github-actions[bot] commented 8 months ago

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.

github-actions[bot] commented 7 months ago

Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers.