calogica / dbt-expectations

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

expect_column_values_to_be_of_type #196

Closed pixie79 closed 1 year ago

pixie79 commented 1 year ago

I have been trying this test using the DBT-Glue adapter which I believe uses the dbt-spark plugin underneath however it appears to be casting the list of columns as TEXT which is unsupported.

11:42:15        from (
11:42:15          with relation_columns as (
11:42:15    
11:42:15            
11:42:15            select
11:42:15                cast('GL_HEADER_KEY' as TEXT) as relation_column,
11:42:15    ------------------------------------^^^
11:42:15                cast('STRING' as TEXT) as relation_column_type
11:42:15            union all

As far as I can tell that is generated via - dbt_utils.type_string(), i think it should be CASTing as STRING?

Is the a way to override this?

clausherther commented 1 year ago

Hi @pixie79 - couple of things:

clausherther commented 1 year ago

In the short term you could try implementing a version of type_string() locally, something like

{% macro spark__type_string() -%}
    STRING
{%- endmacro %}
pixie79 commented 1 year ago

@clausherther Thanks that temp fix does solve the issue. I will try and open an issue on dbt-core.