Hive数子IP与字符串IP之间的转换

字符串IP:247.164.62.58  对应的   数字IP:4154736186

数子IP=>字符串IP
select concat_ws('.',conv(substr(hex(4154736186),1,2),16,10),conv(substr(hex(4154736186),3,2),16,10),conv(substr(hex(4154736186),5,2),16,10),conv(substr(hex(4154736186),7,2),16,10))


字符串IP=>数字IP
cast(split("247.164.62.58","\\.")[0] as bigint)*256*256*256+cast(split("247.164.62.58","\\.")[1] as bigint)*256*256+cast(split("247.164.62.58","\\.")[2] as bigint)*256+cast(split("247.164.62.58","\\.")[3] as bigint)
posted @ 2021-09-17 13:13  小碗吃不胖的  阅读(283)  评论(0编辑  收藏  举报