我無法在Web上找到任何文檔,在AWS Redshift中是否存在類似INET_ATON的文檔。所以我想它還沒有,但我想知道是否可以有某種解決方法。順便說一句,我正在使用max_mind數據。INET_ATON等效於AWS Redshift
1
A
回答
0
我最終創建了一個Python包裝器(這是我使用的主要語言),它將IP字符串轉換爲數字,然後使用它。
2
一種解決辦法是,你可以使用:
SELECT ipAddr,
SPLIT_PART(ipAddr, '.', 1)* 16777216::bigint +
SPLIT_PART(ipAddr, '.', 2)* 65536::bigint +
SPLIT_PART(ipAddr, '.', 3)* 256::bigint +
SPLIT_PART(ipAddr, '.', 4)::bigint AS addressRange
FROM <your_table) LIMIT 5
addressRange應匹配的MaxMind startIpNum < addressRange < endIpNum。
0
我裝在同名表格全國塊和位置的CSV,並與下面的查詢
INSERT INTO dim.geoip_country
SELECT
SPLIT_PART(first_ip, '.', 1) * 16777216::BIGINT
+ SPLIT_PART(first_ip, '.', 2) * 65536::BIGINT
+ SPLIT_PART(first_ip, '.', 3) * 256::BIGINT
+ SPLIT_PART(first_ip, '.', 4)::BIGINT AS ip_inf,
SPLIT_PART(first_ip, '.', 1) * 16777216::BIGINT
+ SPLIT_PART(first_ip, '.', 2) * 65536::BIGINT
+ SPLIT_PART(first_ip, '.', 3) * 256::BIGINT
+ SPLIT_PART(first_ip, '.', 4)::BIGINT
+ POW(2, 32 - mask_bits)::BIGINT AS ip_sup,
network,
isocode2,
name,
continent_code,
continent_name,
is_anonymous_proxy,
is_satellite_provider
FROM (
SELECT
b.network,
SPLIT_PART(b.network, '/', 1) AS first_ip,
SPLIT_PART(b.network, '/', 2)::INTEGER AS mask_bits,
l.country_iso_code AS isocode2,
l.country_name AS name,
l.continent_code AS continent_code,
l.continent_name AS continent_name,
b.is_anonymous_proxy::BOOLEAN AS is_anonymous_proxy,
b.is_satellite_provider::BOOLEAN AS is_satellite_provider
FROM ext.geoip2_country_blocks_ipv4 b
JOIN ext.geoip2_country_locations_en l
ON b.geoname_id = l.geoname_id
)
加盟
相關問題
- 1. 等效於mongodb中的INET_ATON()
- 2. windows等價於inet_aton
- 3. 用於INET_NTOA和INET_ATON的.NET等價物
- 4. 適用於AWS RedShift的沙箱版本
- 5. AWS Redshift列限制?
- 6. AWS Redshift + Tableau Performance Booster
- 7. AWS Redshift的負載測試
- 8. AWS Redshift最高限額
- 9. AWS Redshift表值函數
- 10. AWS Redshift數據處理
- 11. 註冊AWS Redshift活動
- 12. 使用JDBC連接AWS Redshift
- 13. PHP中的ip2long()是否等於MySQL中的INET_ATON()函數?
- 14. 等效於WM_MOVE
- 15. 等效於'@ECHO ON'的Unix等效
- 16. AWS CloudFormation /var/log/cloud-init-output.log等效於Windows AMI
- 17. 什麼是AWS等效於Firebase實時數據庫?
- 18. AWS Redshift alter append命令不適用於插入數據
- 19. AWS Redshift:用於模擬/鏡像紅移的庫
- 20. AWS Flow Framework的開源等效
- 21. VLOOKUP等效於MySQL
- 22. __LINE__等效於Javascript
- 23. ereg_replace等效於C#
- 24. View.Frame等效於Android
- 25. powershell等效於SIGHUP
- 26. gluProject等效於Javascript
- 27. ifdef等效於TCL
- 28. VBA:GoalSeek等效於C#
- 29. Android等效於JTextArea
- 30. ArrayList.ensureCapacity等效於Javascript