str_to_map
function
Applies to: Databricks SQL Databricks Runtime
Creates a map after splitting the input into key-value pairs using delimiters.
Syntax
str_to_map(expr [, pairDelim [, keyValueDelim] ] )
Arguments
expr
: AnSTRING
expression.pairDelim
: An optionalSTRING
literal defaulting to','
that specifies how to split entries.keyValueDelim
: An optionalSTRING
literal defaulting to':'
that specifies how to split each key-value pair.
Returns
A MAP
of STRING
for both keys and values.
Both pairDelim
and keyValueDelim
are treated as regular expressions.
Examples
> SELECT str_to_map('a:1,b:2,c:3', ',', ':');
{a -> 1, b -> 2, c -> 3}
> SELECT str_to_map('a');
{a->NULL}