I have a Dataset<Row>
in spark just like:
+----+-------+
| age| name|
+----+-------+
| 15|Michael|
| 30| Andy|
| 19| Justin|
+----+-------+
Now I want to add a column that has value of string value of age
plus string value of name
,like:
+----+-------+-----------+
| age| name|cbdkey |
+----+-------+-----------+
| 15|Michael| 15Michael|
| 30| Andy| 30Andy |
| 19| Justin| 19Justin |
+----+-------+-----------+
I use:
df.withColumn("cbdkey",col("age").+(col("name"))).show()
But all value of new column cbdkey
is null
. So,How should I do this?Thanks in advance.