calogica / dbt-expectations

Port(ish) of Great Expectations to dbt test macros
https://calogica.github.io/dbt-expectations/
Apache License 2.0
989 stars 120 forks source link

[BUG] With expect expect_column_values_to_be_of_type test #298

Open adrikosm opened 5 months ago

adrikosm commented 5 months ago

Is this a new bug in dbt-expectations?

Current Behavior

So the issue is coming directly from the - dbt_expectations.expect_column_values_to_be_of_type:. When testing with text, string ,or char values it returns 1 warning even though it should not.

Note: When running the --store-failures command the first row returns that it has found a varchar value. This is the same whether the column_type is text string or char.

Expected Behavior

The example code i am using is :

  - name: table_name
    description: >
      Table Description
    columns:
      - name: text_only_column
        description: Column that only has text values 
        tests:
          - dbt_expectations.expect_column_values_to_be_of_type:
              column_type: text
              config:
                severity: warn
                warn_if: "!=0"
          - unique:
              config:
                severity: warn
                warn_if: "!=0"

So i expect the run to not reproduce any errors since all of the values inside are handpicked to be text.

Steps To Reproduce

I have provided the code example along side the packages used in order to reproduce that error.

Environment

- OS: MacOS
- Python: 3.10.9
- dbt: 1.7.4
- dbt-snowflake-connector: 1.7.1
- dbt-expectations: 0.10.1 

Which database adapter are you using with dbt?

I am using snowflake adapter

Additional Context

Packages used

packages:
  - package: dbt-labs/codegen
    version: 0.11.0
  - package: calogica/dbt_expectations
    version: 0.10.1
  - package: dbt-labs/dbt_utils
    version: 1.1.1
  - package: Snowflake-Labs/dbt_constraints
    version: 0.6.2