Spark SQL - Convert Delimited String to Map using str_to_map Function

visibility 16 access_time 24 days ago languageEnglish timeline Stats
timeline Stats
Page index 0.64

Spark SQL function str_to_map can be used to split the delimited string to key value pairs.

Function syntax

 str_to_map(text[, pairDelim[, keyValueDelim]]) 

The default values for the parameters are:

  • pairDelim: ,
  • keyValueDelim: :

Code snippets

The following code snippets convert string to map object:

spark-sql> select str_to_map('1:a,2:b,3:c,4:d');
str_to_map(1:a,2:b,3:c,4:d, ,, :)
copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

More from Kontext
Spark SQL - LAG Window Function
visibility 6,385
thumb_up 0
access_time 2 years ago
Spark SQL - Map Functions
visibility 1,927
thumb_up 0
access_time 2 years ago