mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-11 17:02:25 +00:00
Merge pull request #72652 from pakud/patch-2
Adding example for JSONExtract which refers to a nested entry in JSON
This commit is contained in:
commit
6262bfdc87
@ -733,6 +733,18 @@ SELECT JSONExtract('{"day": "Thursday"}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday
|
||||
SELECT JSONExtract('{"day": 5}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Friday'
|
||||
```
|
||||
|
||||
Referring to a nested values by passing multiple indices_or_keys parameters:
|
||||
```
|
||||
SELECT JSONExtract('{"a":{"b":"hello","c":{"d":[1,2,3],"e":[1,3,7]}}}','a','c','Map(String, Array(UInt8))') AS val, toTypeName(val), val['d'];
|
||||
```
|
||||
Result:
|
||||
```
|
||||
┌─val───────────────────────┬─toTypeName(val)───────────┬─arrayElement(val, 'd')─┐
|
||||
│ {'d':[1,2,3],'e':[1,3,7]} │ Map(String, Array(UInt8)) │ [1,2,3] │
|
||||
└───────────────────────────┴───────────────────────────┴────────────────────────┘
|
||||
```
|
||||
|
||||
|
||||
### JSONExtractKeysAndValues
|
||||
|
||||
Parses key-value pairs from JSON where the values are of the given ClickHouse data type.
|
||||
|
Loading…
Reference in New Issue
Block a user