Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split a column?

I would like to see if I can split a column in spark dataframes. Like this,

Select employee, split(department,"_") from Employee
like image 848
ashK Avatar asked Mar 24 '16 12:03

ashK


1 Answers

Try this:

SELECT explode(split(str, '_'))

Or this:

SELECT split(str, ' ')[0] as part1, split(str, ' ')[1] as part2
like image 51
David Griffin Avatar answered Oct 12 '22 02:10

David Griffin