regex - 在Hive中使用regexp_extract提取数据

标签 regex hadoop hive

{'offercode': u'5100003454', 'offer': 'Book 14 days in Advance and Get 15% Off\r\n', 'original_baseprice': [[3700.0], [3700.0]], 'taxbreakup': {'taxinfo': {'othertaxon_display': u'Sell Rate', 'servtax': 0.0, 'luxtaxon_display': u'Sell Rate', 'servtaxon_display': u'Sell Rate', 'nettservicetaxflag': True, 'servtaxon': u'sellrate', 'othertax': 0.0, 'taxonextrabedflag': True, 'luxtaxon': u'sellrate', 'taxincluded': False, 'taxcode': u'7500003113', 'luxtax': 18.66, 'othertaxon': u'sellrate'}, 'LT': 1174, 'OT': 0, 'ST': 0}, 'baseprice': [[3145.0], [3145.0]], 'success': True, 'extraguest': [[0], [0]], 'extraguest_nett': [[0], [0]], 'original_nettbreakup': [[2775.0], [2775.0]], 'original': [[3700.0], [3700.0]]}    

我无法在 hive 中获取'LT':1174,'OT':0,'ST':0值

我已经尝试过了

regexp_extract(string,“\'LT \':(。?)”,1)作为LT,regexp_extract(string,“\'OT \':(。?)”,1)作为OT,regexp_extract(string,“\ 'ST \':(。*?)“,1)

最佳答案

SELECT 
regexp_replace(regexp_extract(string,"\'LT\': (.*?) ", 1), ',', '') as LT,
regexp_replace(regexp_extract(string,"\'OT\': (.*?) ", 1), ',', '') as OT,
regexp_replace(regexp_extract(string,"\'ST\': (.*?) ", 1 ), '},', '') as ST

关于regex - 在Hive中使用regexp_extract提取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34895845/

相关文章:

hadoop - DSE 4.7 中奇怪的 dse hive 集成

python - 在多线程python中查找cpu-hogging插件

javascript - 大写每个单词的第一个字母,\b\w 也适用于 I'm

java - 将 BufferedImage 或 ImageIO 转换为 ByteBuffer

hadoop - 将Oozie协调器工作流程参数传递给工作流程

regex - Hive regexp_replace 替换反斜杠失败

Python:使用正则表达式创建不重复条目的数组

mysql - 如何从 mysql 中的字符串中选择一个精确的子字符串而不是另一个?

hadoop - HDFS 复制因子 - 最小化数据丢失风险

mysql - 从空的配置单元表传递增量值