Hive的join表连接查询的一些注意事项

Hive支持的表连接查询的语法:

 1     join_table:  
 2         table_reference JOIN table_factor [join_condition]  
 3       | table_reference {LEFT|RIGHT|FULL} [OUTER] JOIN table_reference join_condition  
 4       | table_reference LEFT SEMI JOIN table_reference join_condition  
 5       | table_reference CROSS JOIN table_reference [join_condition] (as of Hive 0.10)  
 6       
 7     table_reference:  
 8         table_factor  
 9       | join_table  
10       
11     table_factor:  
12         tbl_name [alias]  
13       | table_subquery alias  
14       | ( table_references )  
15       
16     join_condition:  
17         ON equality_expression ( AND equality_expression )*  
18       
19     equality_expression:  
20         expression = expression 

 hive只支持等连接,外连接,左半连接。hive不支持非相等的join条件(可以通过其他方式实现),因为它很难在map/reduce job实现这样的条件。而且,hive可以join两个以上的表。

猜你喜欢

转载自www.cnblogs.com/shujuxiong/p/9718913.html