Regex 使用点';拆分';不';t使用hive-e“工作”&引用;即使放了双斜杠
我使用下面的查询来解析以点('.')分隔的数据。以下查询在从配置单元控制台激发时工作正常。我得到如下正确的值:Regex 使用点';拆分';不';t使用hive-e“工作”&引用;即使放了双斜杠,regex,hadoop,hive,Regex,Hadoop,Hive,我使用下面的查询来解析以点('.')分隔的数据。以下查询在从配置单元控制台激发时工作正常。我得到如下正确的值: v=WijimLM4Khb5YUVrh7kl4bOWx YtIOtZwTRJ 1397755516 1397755721 1397755739 1 9 但是当我使用hive-e“”使用相同的查询时。它无法解析数据,解析列结果为空 null null null null null null null 查询: select split(regexp_extract(cookie
v=WijimLM4Khb5YUVrh7kl4bOWx YtIOtZwTRJ 1397755516 1397755721 1397755739 1 9
但是当我使用hive-e“”使用相同的查询时。它无法解析数据,解析列结果为空
null null null null null null null
查询:
select split(regexp_extract(cookie,'v=[^&\n\;\" ]*',0),'\\.')[0],
split(regexp_extract(cookie,'v=[^&\n\;\" ]*',0),'\\.')[1],
split(regexp_extract(cookie,'v=[^&\n\;\" ]*',0),'\\.')[2],
split(regexp_extract(cookie,'v=[^&\n\;\" ]*',0),'\\.')[3],
split(regexp_extract(cookie,'v=[^&\n\;\" ]*',0),'\\.')[4],
split(regexp_extract(cookie,'v=[^&\n\;\" ]*',0),'\\.')[5],
split(regexp_extract(cookie,'v=[^&\n\;\" ]*',0),'\\.')[6] from tmp1 where cookie is not null
数据:
v=oijim124Khb5YUVrh7kl4bOWx.tyIOt6wTRJ.1397755516.1397755721.1397755739.1.9
我们需要在正则表达式中使用
[.]
,以使查询正常工作。它将为您提供正确的解析数据
hive -e "select split(regexp_extract(cookie,'v=[^&\n\;\" ]*',0),'[.]')[0],
split(regexp_extract(cookie,'v=[^&\n\;\" ]*',0),'[.]')[1],
split(regexp_extract(cookie,'v=[^&\n\;\" ]*',0),'[.]')[2],
split(regexp_extract(cookie,'v=[^&\n\;\" ]*',0),'[.]')[3],
split(regexp_extract(cookie,'v=[^&\n\;\" ]*',0),'[.]')[4],
split(regexp_extract(cookie,'v=[^&\n\;\" ]*',0),'[.]')[5],
split(regexp_extract(cookie,'v=[^&\n\;\" ]*',0),'[.]')[6] from tmp1 where cookie is not null"