add alias str_to_map and mapFromString for extractKeyValuePairs

This commit is contained in:
flynn 2023-05-03 15:46:17 +00:00
parent 695b5b9f7b
commit 236a0d9da0
3 changed files with 46 additions and 0 deletions

View File

@ -228,6 +228,8 @@ REGISTER_FUNCTION(ExtractKeyValuePairs)
```)") ```)")
); );
factory.registerAlias("str_to_map", NameExtractKeyValuePairs::name, FunctionFactory::CaseInsensitive);
factory.registerAlias("mapFromString", NameExtractKeyValuePairs::name);
} }
} }

View File

@ -304,3 +304,25 @@ WITH
SELECT SELECT
x; x;
{} {}
WITH
str_to_map('name:neymar, age:31 team:psg,nationality:brazil') AS s_map,
CAST(
arrayMap(
(x) -> (x, s_map[x]), arraySort(mapKeys(s_map))
),
'Map(String,String)'
) AS x
SELECT
x;
{'age':'31','name':'neymar','nationality':'brazil','team':'psg'}
WITH
mapFromString('name:neymar, age:31 team:psg,nationality:brazil') AS s_map,
CAST(
arrayMap(
(x) -> (x, s_map[x]), arraySort(mapKeys(s_map))
),
'Map(String,String)'
) AS x
SELECT
x;
{'age':'31','name':'neymar','nationality':'brazil','team':'psg'}

View File

@ -426,3 +426,25 @@ WITH
) AS x ) AS x
SELECT SELECT
x; x;
WITH
str_to_map('name:neymar, age:31 team:psg,nationality:brazil') AS s_map,
CAST(
arrayMap(
(x) -> (x, s_map[x]), arraySort(mapKeys(s_map))
),
'Map(String,String)'
) AS x
SELECT
x;
WITH
mapFromString('name:neymar, age:31 team:psg,nationality:brazil') AS s_map,
CAST(
arrayMap(
(x) -> (x, s_map[x]), arraySort(mapKeys(s_map))
),
'Map(String,String)'
) AS x
SELECT
x;