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

[Epic] Cross-database cast macro #9976

Open
15 of 16 tasks
dbeatty10 opened this issue Apr 18, 2024 · 0 comments
Open
15 of 16 tasks

[Epic] Cross-database cast macro #9976

dbeatty10 opened this issue Apr 18, 2024 · 0 comments
Assignees

Comments

@dbeatty10
Copy link
Contributor

dbeatty10 commented Apr 18, 2024

This epic comprises the changes across dbt Labs repos necessary to implement a cross-database cast macro as described in dbt-labs/dbt-adapters#84.

Implementation

The cast function is specified in ISO/IEC 9075-2 (part 2 of the SQL standard), so there is a natural adapter-agnostic implementation:

cast({{ expression }} as {{ data_type }})

Utility

It can be useful for end-users when they are looking for an adapter-agnostic method to cast a SQL expression to a specific data type.

Having a cross-database cast macro has been suggested as a way to address a variety of things including, but not limited to:

For example, it can be useful in implementations of safe_cast (falling back to cast for types that don't support a try / safe cast, e.g. in snowflake).

dbt-adapters

  1. MichelleArk
  2. enhancement
    dbeatty10

dbt-postgres

  1. cla:yes

dbt-redshift

  1. cla:yes

dbt-snowflake

  1. cla:yes
  2. cla:yes

dbt-bigquery

  1. cla:yes

dbt-spark

  1. cla:yes

Documentation

  1. content dbt-core v1.8 size: small
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant