解析 IP 并将其连接到 BigQuery 上具有一系列整数表示的另一个表

Posted

技术标签:

【中文标题】解析 IP 并将其连接到 BigQuery 上具有一系列整数表示的另一个表【英文标题】:Parsing IP and joining it to another table with a range of integer representation on BigQuery 【发布时间】:2014-01-28 08:04:04 【问题描述】:

我需要从我拥有的第一个表(域)中解析 IP,并将其与整数表示范围相匹配,并将域中的 IP 与 BigQuery 上 IP_location 中的国家/地区相匹配

SELECT domain.IP, IP_location.Country
FROM   [webs.domain]
JOIN   [webs.IP_location]
       ON PARSE_IP(rdns.IP) >= IP_location.integer_start 
       AND PARSE_IP(rdns.IP) <= IP_location.integer_end;

当我使用这个查询时,我得到了一个错误

错误:ON 子句必须是 AND of = 比较每个表中的一个字段名称,所有字段名称都以表名称为前缀。

【问题讨论】:

看看这个...***.com/questions/19618105/…. 【参考方案1】:

通常,如您所述,对不等式进行连接的方法是使用带有 WHERE 子句的CROSS JOIN

SELECT domain.IP, location.Country
FROM   [webs.domain] domain
CROSS JOIN [webs.IP_location] location
WHERE PARSE_IP(domain.IP) >= location.integer_start 
  AND PARSE_IP(domain.IP) <= location.integer_end;

请注意,如果此查询耗尽资源,您可能需要使用 CROSS JOIN EACH。 另外,我稍微调整了您的查询,因为 PARSE_IP 调用使用的是 rdns.IP,我假设您的意思是 domain.IP。

【讨论】:

以上是关于解析 IP 并将其连接到 BigQuery 上具有一系列整数表示的另一个表的主要内容,如果未能解决你的问题,请参考以下文章

如何在运行时手动创建服务并将其连接到 typescript Angular 2 中的组件

如何在 Windows 8.1 上安装 SDL 并将其连接到 Visual Studio Community 2013

在 UILabel 中处理触摸事件并将其连接到 IBAction

无法添加插槽并将其连接到按钮

使用 recompose setStatic 并将其连接到 redux (nextjs)

bigquery:加入“结构”列