ODPS中,实现两表关联,但能关联的字段为包含关系,怎么实现,谢谢
你好,你可以通过TRANS_ARRAY列转行函数,将一行数据转化为多行,将关联的key打开后再进行关联,使用如下,谢谢
+----------+----------+------------+
| login_id | login_ip | login_time |
+----------+----------+------------+
| wangwangA | 192.168.0.1,192.168.0.2 | 20120101010000,20120102010000 |
| wangwangB | 192.168.45.10,192.168.67.22,192,168.6.3 | 20120111010000,20120112010000,20120223080000 |
执行sql:
select trans_array(1, ',', login_id, login_ip, login_time) as (login_id,login_ip,login_time) from t_table;
产生的数据是
+----------+----------+------------+
| login_id | login_ip | login_time |
+----------+----------+------------+
| wangwangB | 192.168.45.10 | 20120111010000 |
| wangwangB | 192.168.67.22 | 20120112010000 |
| wangwangB | 192.168.6.3 | 20120223080000 |
| wangwangA | 192.168.0.1 | 20120101010000 |
| wangwangA | 192.168.0.2 | 20120102010000 |
赞0
踩0