mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
add alias str_to_map and mapFromString for extractKeyValuePairs
This commit is contained in:
parent
695b5b9f7b
commit
236a0d9da0
@ -228,6 +228,8 @@ REGISTER_FUNCTION(ExtractKeyValuePairs)
|
||||
└──────────────────┘
|
||||
```)")
|
||||
);
|
||||
factory.registerAlias("str_to_map", NameExtractKeyValuePairs::name, FunctionFactory::CaseInsensitive);
|
||||
factory.registerAlias("mapFromString", NameExtractKeyValuePairs::name);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -304,3 +304,25 @@ WITH
|
||||
SELECT
|
||||
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'}
|
||||
|
@ -426,3 +426,25 @@ WITH
|
||||
) AS x
|
||||
SELECT
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user