我在hive中有json,每个json都有不同的键,我想获取所有键并使用get_json_object来获取值。那么,是否有hive查询获取json密钥呢?
import heapq
s1 = {'val': 0}
s2 = {'val': 10}
s3 = {'val': 5}
s4 = {'val': 4}
s5 = {'val': 6}
s6 = {'val': 7}
s7 = {'val': 3}
shapelets = [s1, s2, s3, s4, s5, s6, s7]
heapq.nlargest(5,[dct['val'] for dct in shapelets])
# [10, 7, 6, 5, 4]
由于
答案 0 :(得分:0)
使用REGEXP_REPLACE
!!
SELECT
REGEXP_REPLACE(
REGEXP_REPLACE(json,'\'(\\w+)\': \\w+,', '$1,')
, '[{} ]', '')
FROM json_table