Hi@Deepak,
In your test class you passed empid as string, that's why it shows nullable=true. So you have to import the below package.
import org.apache.spark.sql.types
You can use these kind of codes in your program.
df.withColumn("empid", $"empid".cast(IntegerType))
df.withColumn("username", $"username".cast(StringType))