4.2.5 Multi Insert

对于从同一份源表往不同的表中插数据,可以采用multi insert语法,减少job个数

FROM (SELECT a.status, b.school, b.gender 
        FROM status_updates a JOIN profiles b 
             ON (a.userid = b.userid anda.ds='2009-03-20' ) 
      ) subq1 
INSERT OVERWRITE TABLE gender_summary PARTITION(ds='2009-03-20') 
    SELECT subq1.gender, COUNT(1) GROUP BY subq1.gender 
INSERT OVERWRITE TABLE school_summary PARTITION(ds='2009-03-20') 
    SELECT subq1.school, COUNT(1) GROUP BY subq1.school

上述查询语句使用了Multi-Insert特性连续insert了两张不同的表,减少了一轮MapReduce操作。

results matching ""

    No results matching ""