adding column with the length of other column as value using scala

Viewed 2068

I have task to calculate each column length and add message to "errorMsg" column. I am able to filter the record based on length but not able to append message in new column.

eg. I want find out only invalid records with message on new column "ErrorMsg"

recordlength=4

InputDataFrame-             
+------+
| value|
+------+
|Pra   |
|Akshay|
|  Raju|
|Shakti|
|xyz   |
+------+

OutputDataFrame

+------+------------------------+
| value|ErrorMsg                |
+------+------------------------+
|Pra   |Less Than total Length
|Akshay|Greater than total length 
|Shakti|Greater than total length
|xyx   |Less than total length
+------+-------------------------

Where raju is my true record it goes to valid records without message.

1 Answers
Related