Skip to content

generate_surrogate_key macro fails for boolean types in Redshift #1016

Open
@roops-ma

Description

@roops-ma

Describe the bug

When I run generate_surrogate_key macro for a boolean column, it fails with below error.

cannot cast type boolean to character varying

Steps to reproduce

Run a model with the macro like below
SELECT col1, {{ dbt_utils.generate_surrogate_key(cols_to_hash) }} as sk
FROM foo;

Expected results

expecting hash value for the list of column values provided regardless of the data type of each column.

Actual results

Fails with below error
cannot cast type boolean to character varying

System information

The contents of your packages.yml file:

Which database are you using dbt with?

  • postgres
  • [*] redshift
  • bigquery
  • snowflake
  • other (specify: ____________)

The output of dbt --version:

Core:
  - installed: 1.10.0-b2
  - latest:    1.9.4     - Ahead of latest version!

Plugins:
  - redshift: 1.9.3 - Up to date!
  - postgres: 1.9.0 - Up to date!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions