cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to remove more than 4 byte characters using pyspark in databricks?

eimis_pacheco
Contributor

Hi community,

We have the need of removing more than 4 byte characters using pyspark in databricks since these are not supported by amazon Redshift. Does someone know how can I accomplish this?

Thank you very much in advance

Regards

1 REPLY 1

Shalabh007
Honored Contributor

assuming you are having a string type column in pyspark dataframe, one possible way could be

  1. identify total number of characters for each value in column (say
  2. identify no of bytes taken by each character (say b)
  3. use substring() function to select first n characters where n = floor(4 / b)

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group