[Constraints] Constraint enforcement fails for types that cannot be cast to directly using cast
function
#166
Labels
type:bug
Something isn't working as documented
Is this a new bug?
Current Behavior
While enforcing a model contract,
dbt build
does aCAST(null as GEOGRAPHY)
which is invalid for Snowflake, because we are not using the adapter-specific cast macro in get_empty_schema_sql here.Casting null to
GEOGRAPHY
orGEOMETRY
via thecast
function is invalid for Snowflake, and needs to beto_geography
orto_geometry
instead (See https://docs.snowflake.com/en/sql-reference/functions/to_geography).This can be solved at the base adapter level now that we have a global, overridable
cast
macro. Snowflake provides an override that would handle the geography and geometry cases. No other first-party maintained adapter has a custom override yet.Expected Behavior
dbt is able to enforce contracts that include types that cannot be cast to directly via the
cast
function such asgeometry
andgeography
in Snowflake.Steps To Reproduce
dbt build
and see the error message:Relevant log output
No response
Environment
Additional Context
No response
The text was updated successfully, but these errors were encountered: