其他分享
首页 > 其他分享> > Hive数子IP与字符串IP之间的转换

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)

标签:数子,conv,IP,Hive,62.58,4154736186,256,247.164
来源: https://www.cnblogs.com/ZeroITStudy/p/15304213.html