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

Is there a function similar to split_part, json_extract_scalar?

dulu
New Contributor III

I am using spark_sql version 3.2.1. Is there a function that can replace

split_part,

json_extract_scalar

are not?

3 REPLIES 3

Ankush
New Contributor II

pyspark.sql.functions.

get_json_object

(colpath)[source]

Extracts json object from a json string based on json path specified, and returns json string of the extracted json object. It will return null if the input json string is invalid.

โ€‹

Hi @Du Luโ€‹, We havenโ€™t heard from you since the last response from @Ankush Jadhaoโ€‹โ€‹โ€‹, and I was checking back to see if his suggestions helped you.

Or else, If you have any solution, please share it with the community, as it can be helpful to others.

Also, Please don't forget to click on the "Select As Best" button whenever the information provided helps resolve your question.

dulu
New Contributor III

Thanks @Ankush Jadhaoโ€‹  for answer, I tried but only returns the first result in the cell. They seem to only take the first character with the correct result. I need out put like the table below.

I have the following input:

hinh22 

I am looking for a way to split the characters in the item_order_detail column into 2 columns itemID and itemName. As below output table uses SQL function in databricks with spark_sql version 3.2.1.

hinh223 

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