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

[Bug]: dbt.hash macro expands with unsupported 'TEXT' datatype #189

Open
1 task done
maxfirman opened this issue Jun 27, 2023 · 3 comments
Open
1 task done

[Bug]: dbt.hash macro expands with unsupported 'TEXT' datatype #189

maxfirman opened this issue Jun 27, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@maxfirman
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The builtin dbt hash macro expands to include a cast to TEXT which is not supported in Dremio. i.e

dbt.hash('foo')

resolves to

md5(cast(foo as TEXT))

Expected Behavior

The macro should cast to a supported data type i.e:

md5(cast(foo as VARCHAR))

Steps To Reproduce

Create a macro to log the output of dbt.hash

{%- macro log_hash(field) -%}
  {{ log(dbt.hash('foo'), True) }}
{% endmacro %}

execute:

dbt run-operation log_hash --args '{"field": "a"}'

output:

10:29:23  Running with dbt=1.4.5
10:29:24  md5(cast(foo as TEXT))

Environment

- OS: Ubuntu 22
- dbt-dremio: 1.4.5
- Dremio Software: 24.0.2
- Dremio Cloud: No

Relevant log output

No response

@maxfirman maxfirman added the bug Something isn't working label Jun 27, 2023
@maxfirman
Copy link
Author

maxfirman commented Jun 27, 2023

You can see where the hash macro is implemented here

I think the fix would be for the Dremio adapter to override the TYPE_LABELS dictionary in the Column class as shown here in the BigQuery adapter.

@Conq1
Copy link

Conq1 commented Jun 30, 2023

Until a fix is in place you can create you own macro as a workaround. (you probably already know this):

{% macro dremio__hash(field) -%}
    md5(cast({{ field }} as varchar))
{%- endmacro %}

I really love how easy it is to make these adapter specific macros. :)

@maxfirman
Copy link
Author

Thanks @Conq1. I'm able to work around the problem by implementing dremio__hash as you describe. I agree its very useful to be able to do this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants