4

I want to concatenate two column in dataframe as one column here I want to merge nameFirst and nameLast as column called FULL Name

+---------+---------+--------+
| playerID|nameFirst|nameLast|
+---------+---------+--------+
|aardsda01|    David| Aardsma|
|aaronha01|     Hank|   Aaron|
|aaronto01|   Tommie|   Aaron|
| aasedo01|      Don|    Aase|
+---------+---------+--------+

I'm trying this code :

sqlContext.sql("SELECT playerID,(nameFirst+nameLast) as full_name FROM Master")

but it returns

+---------+---------+
| playerID|full_name|
+---------+---------+
|aardsda01|     null|
|aaronha01|     null|
|aaronto01|     null|
| aasedo01|     null|

any help please

0

1 Answer 1

5

Just use concat function:

sqlContext.sql("SELECT playerID, concat(nameFirst, nameLast) as full_name FROM Master")
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.