Set Not null changes Data type

Box_clown
Databricks Partner

Hello,

Just found this issue this week and thought I would ask. An Alter Table alter column set not null is changing a varchar(x) data type to string type. 

I believe this should happen in most environments so I wouldn't need to supply code...

Create a delta table:

Script 01: Create table [schema].[testTbl_01] (tbl_id int not null, test_01 varchar(20) not null) using delta [location]

Run a table description or show table create the table will look like you wanted.

Script 02: alter table [schema].[testTbl_01] add column New_01 varchar(3)

Run a table description or show table create the table will look like you wanted.

Script 03: alter table [schema].[testTbl_01] alter column New_01 set not null

Run a table description or show table create the table and the newly created/added column will now be a string data type. 

Our cluster is currently 14.3 and was updated to that in May 2024. This week is when we noticed this new behavior but not sure 100% when it started. I was able to add a new column last week and this did not happen.