Noopur_Nigam
Databricks Employee
Databricks Employee

Hi @JohnJustus If you see closely in .withColumn ("Category", when (length("Bin")==4,'SMALL LOT'), when (length("Bin")==7,'RACKING'), otherwise('FLOOR')), withcolumn would take 2 parameters. The first parameter as a string and the second as the column. However in your code, you are passing 3 parameters i.e. first is string and the other two are when conditions so the last when condition is being considered as an extra parameter in withcolumn function. This is the reason removing last when is resolving the issue.