I am trying to add a column based on a case when statement mapping status to status names. This is in Databricks, and i'm wondering if i'm having an issue with permissions or if my syntax is off somewhere. A similar statement worked in SQL server.
ALTER TABLE dbo.table
ADD status_name as (CASE WHEN status = '0' THEN 'Pink'
WHEN status = '9' THEN 'Green'
WHEN status = '8' THEN 'Blue'
WHEN status = '2' THEN 'Red'
ELSE 'Other'
END);
This is the error message I am getting:
Error in SQL statement: ParseException: no viable alternative at input 'ALTER TABLE db.table\nADD status_name'(line 2, pos 4)
Anyone know where i'm going wrong here? Shouldn't the syntax be identical between data-bricks and sql server? The table names are different in Databricks.