hive ipv4与十进制整数的转换
Posted AI算法攻城狮
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hive ipv4与十进制整数的转换相关的知识,希望对你有一定的参考价值。
1、ipv4转十进制整数
CAST(split(ip, '\\\\.') [0] * 256 * 256 * 256 + split(ip, '\\\\.') [1] * 256 * 256 + split(ip, '\\\\.') [2] * 256 + split(ip, '\\\\.') [3] AS bigint)
2、十进制整数转ipv4
select concat_ws('.'
,conv(substr(hex(cast('3097097128' as bigint)),1,2),16,10)
,conv(substr(hex(cast('3097097128' as bigint)),3,2),16,10)
,conv(substr(hex(cast('3097097128' as bigint)),5,2),16,10)
,conv(substr(hex(cast('3097097128' as bigint)),7,2),16,10)
);
以上是关于hive ipv4与十进制整数的转换的主要内容,如果未能解决你的问题,请参考以下文章