How to Split a Column?

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

1 Answer

Try this:

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

Or this:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Chloe Bennett
Author

Chloe Bennett

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.