Closed graciegoheen closed 9 months ago
select try_cast(1 as NUMBER);
works on BQ and postgres
Is this an update to the safe_cast
macro, just add literals to everything? But that macro accepts any expression..
If the jinja type is number, then add string literal
https://docs.getdbt.com/reference/dbt-jinja-functions/cross-database-macros#safe_cast
@MichelleArk was this fixed as part of your adapter case-sensitivity work?
This change was pulled into https://github.com/dbt-labs/dbt-snowflake/pull/896 here.
Is this a new bug in dbt-snowflake?
Current Behavior
This unit test results in a SQL compilation error:
That's because this doesn’t work in snowflake:
select try_cast(1 as NUMBER);
But this does:select try_cast('1' as NUMBER);
So does this, but gross:select try_cast(to_numeric(1) as NUMBER) as my_col;
so does this:select cast(1 as NUMBER);
(but dbt doesn't have a cast macro, only safe_cast https://github.com/dbt-labs/dbt-adapters/issues/84)If I update my unit test definition to wrap all of the numbers in double quotes, then this error goes away.
Expected Behavior
I should be able to have numbers in my unit test definition without wrapping them in quotes.
Environment
No response
Additional Context
No response