ashK
ashK

Reputation: 733

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

Upvotes: 17

Views: 48236

Answers (1)

David Griffin
David Griffin

Reputation: 13927

Try this:

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

Or this:

SELECT split(str, ' ')[0] as part1, split(str, ' ')[1] as part2

Upvotes: 47

Related Questions