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:ย 

MalformedInputException when using extended ascii characters in dbutils.notebook.exit()

jfpatenaude
New Contributor

I have a specific use case where I call another notebook using the 

dbutils.notebook.run() function. The other notebook do some processing and return a string in the dbutils.notebook.exit() function to the caller notebook. The returned string has some french special characters in it like ร , รฉ, รจ and because of that, the calling notebook executes for about 5 minutes longer than the called notebook and eventually ends with an exception: com.databricks.WorkflowException: java.nio.charset.MalformedInputException: Input length = 1

If I remove the special characters, everything works fine. Same thing If I use the .encode('ascii', 'remove') function on my string, but I need to have the the correct string returned with my accents. Is there a way to preserve my string intact? I'm on the Databricks Runtime Version 13.3 LTS.
 
You can reproduce the behavior using these two simple notebooks.
Caller Notebook:
output = dbutils.notebook.run('called_notebook', 600)
 
Called Notebook:
dbutils.notebook.exit("La mise ร  jour des tables des donnรฉes raffinรฉes est terminรฉe")
1 REPLY 1

jennie258fitz
New Contributor III

@jfpatenaude starbuckssecretmenu wrote:

I have a specific use case where I call another notebook using the 

dbutils.notebook.run() function. The other notebook do some processing and return a string in the dbutils.notebook.exit() function to the caller notebook. The returned string has some french special characters in it like ร , รฉ, รจ and because of that, the calling notebook executes for about 5 minutes longer than the called notebook and eventually ends with an exception: com.databricks.WorkflowException: java.nio.charset.MalformedInputException: Input length = 1

If I remove the special characters, everything works fine. Same thing If I use the .encode('ascii', 'remove') function on my string, but I need to have the the correct string returned with my accents. Is there a way to preserve my string intact? I'm on the Databricks Runtime Version 13.3 LTS.
 
You can reproduce the behavior using these two simple notebooks.
Caller Notebook:
output = dbutils.notebook.run('called_notebook', 600)
 
Called Notebook:
dbutils.notebook.exit("La mise ร  jour des tables des donnรฉes raffinรฉes est terminรฉe")

- Called Notebook

# Called Notebook
output_string = "La mise ร  jour des tables des donnรฉes raffinรฉes est terminรฉe"
# Encode to UTF-8
output_bytes = output_string.encode('utf-8')
## Convert to string format before returnin
dbutils.notebook.exit(output_bytes.decode('utf-8'))

- Caller Notebook

# Caller Notebook
output = dbutils.notebook.run('called_notebook', 600)
# You may want to ensure it's in the right format after calling
output_string = output.encode('utf-8').decode('utf-8')
print(output_string)

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