Created
April 5, 2017 14:56
-
-
Save developer-sdk/044284199311e58ee79316cd87f42f35 to your computer and use it in GitHub Desktop.
hive: str_to_map()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- STR_TO_MAP 사용법 | |
| SELECT STR_TO_MAP("key1: value1, key2: value2, key3: value3", list_delimiter, key_value_delimiter); | |
| -- example #1 | |
| hive> SELECT STR_TO_MAP("key1: value1, key2: value2, key3: value3", ",", ":"); | |
| OK | |
| {"key1":" value1"," key3":" value3"," key2":" value2"} | |
| Time taken: 0.049 seconds, Fetched: 1 row(s) | |
| -- json string to map | |
| hive> SELECT STR_TO_MAP(REPLACE( | |
| > REPLACE( | |
| > REPLACE( | |
| > REPLACE('{ "name": "json", "class": "math", "age": 15 }', '{', '') | |
| > , '}', '') | |
| > , '"', ''), ' ', '') | |
| > , ",", ":") | |
| > ; | |
| OK | |
| {"name":"json","class":"math","age":"15"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment