in most of the cases there are more than 1 middle names.
PySpark Version of this problem :
ua-cam.com/video/Zr6UXftnqOU/v-deo.html
What if middle name includes 2 names?
select celebrity_name,case when regexp_count(celebrity_name,' ')=1 then split_part(celebrity_name,' ',1)
when regexp_count(celebrity_name,' ')=2 then split_part(celebrity_name,' ',1)
else celebrity_name end first_name,
case when regexp_count(celebrity_name,' ')=1 then null
when regexp_count(celebrity_name,' ')=2 then split_part(celebrity_name,' ',2) end middle_name,
case when regexp_count(celebrity_name,' ')=1 then split_part(celebrity_name,' ',-1)
when regexp_count(celebrity_name,' ')=2 then split_part(celebrity_name,' ',-1) end last_name,
from celebrities;--snowflake
Brother please make video on regular basis❤