Reputation: 87
I am trying to replace null values with a blank space but its throwing an error in snowflake.
select
case when CALL_DATE IS NULL then ' ' ELSE CALL_DATE end as CALL_DATE_NEW
from Table_x
Upvotes: 2
Views: 2584
Reputation: 11066
The problem is the derived column CALL_DATE_NEW gets implicitly cast to type timestamp. As the error indicates, you can't specify a space as a timestamp. You can; however, specify a timestamp as a varchar:
create or replace temp table X (CALL_DATE timestamp);
insert into X values ('2021-12-03'), (null);
select case when CALL_DATE IS NULL then ' ' ELSE CALL_DATE end as CALL_DATE_NEW from x; -- Timestamp '' is not recognized
select case when CALL_DATE IS NULL then ' ' ELSE to_varchar(CALL_DATE) end as CALL_DATE_NEW from x; -- Works by keeping the types consistent
Upvotes: 2
Reputation: 1
Date data types can be null or contain data and/or time data. They cannot contain Space. Sorry.
Upvotes: 0