Queries:

create table mydata (mid INT, cid INT,
rating INT)
stored as SEQUENCEFILE;

create external table mydata_stg(mid INT, cid INT,
rating INT, date1 STRING)
row format delimited fields terminated by '\054' lines terminated by '\012'
stored as textfile
location '/user/sudipto/data/hive/text';

from mydata_stg stg
insert overwrite table mydata
select stg.mid, stg.cid, stg.rating;

create table param(mid INT, param DOUBLE)
stored as SEQUENCEFILE;

insert overwrite table param
select mid, pow(avg(rating), 0.5)
from mydata
group by mid;

create table result(cid INT, mid INT, param DOUBLE, rating DOUBLE)
stored as SEQUENCEFILE;

insert overwrite table result
select /*+ MAPJOIN(m)*/ r.cid, m.mid, m.param, r.rating
from mydata r JOIN param m ON (r.mid = m.mid);

explain of the join

ABSTRACT SYNTAX TREE:
  (TOK_QUERY (TOK_FROM (TOK_JOIN (TOK_TABREF mydata r) (TOK_TABREF param m) (= (. (TOK_TABLE_OR_COL r) mid) (. (TOK_TABLE_OR_COL m) mid)))) (TOK_INSERT (TOK_DESTINATION (TOK_TAB result)) (TOK_SELECT (TOK_HINTLIST (TOK_HINT TOK_MAPJOIN (TOK_HINTARGLIST m))) (TOK_SELEXPR (. (TOK_TABLE_OR_COL r) cid)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL m) mid)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL m) param)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL r) rating)))))

STAGE DEPENDENCIES:
  Stage-1 is a root stage
  Stage-4 depends on stages: Stage-1
  Stage-0 depends on stages: Stage-4

STAGE PLANS:
  Stage: Stage-1
    Map Reduce
      Alias -> Map Operator Tree:
        r
          TableScan
            alias: r
            Common Join Operator
              condition map:
                   Inner Join 0 to 1
              condition expressions:
                0 {cid} {rating}
                1 {mid} {param}
              keys:
                0 [Column[mid]]
                1 [Column[mid]]
              outputColumnNames: _col1, _col2, _col3, _col4
              Position of Big Table: 0
              Select Operator
                expressions:
                      expr: _col1
                      type: int
                      expr: _col2
                      type: int
                      expr: _col3
                      type: int
                      expr: _col4
                      type: double
                outputColumnNames: _col1, _col2, _col3, _col4
                Select Operator
                  expressions:
                        expr: _col1
                        type: int
                        expr: _col3
                        type: int
                        expr: _col4
                        type: double
                        expr: _col2
                        type: int
                  outputColumnNames: _col0, _col1, _col2, _col3
                  Select Operator
                    expressions:
                          expr: _col0
                          type: int
                          expr: _col1
                          type: int
                          expr: _col2
                          type: double
                          expr: UDFToDouble(_col3)
                          type: double
                    outputColumnNames: _col0, _col1, _col2, _col3
                    File Output Operator
                      compressed: false
                      GlobalTableId: 1
                      table:
                          input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                          output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
                          serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
                          name: result
      Local Work:
        Map Reduce Local Work
          Alias -> Map Local Tables:
            m
              Fetch Operator
                limit: -1
          Alias -> Map Local Operator Tree:
            m
              TableScan
                alias: m
                Common Join Operator
                  condition map:
                       Inner Join 0 to 1
                  condition expressions:
                    0 {cid} {rating}
                    1 {mid} {param}
                  keys:
                    0 [Column[mid]]
                    1 [Column[mid]]
                  outputColumnNames: _col1, _col2, _col3, _col4
                  Position of Big Table: 0
                  Select Operator
                    expressions:
                          expr: _col1
                          type: int
                          expr: _col2
                          type: int
                          expr: _col3
                          type: int
                          expr: _col4
                          type: double
                    outputColumnNames: _col1, _col2, _col3, _col4
                    Select Operator
                      expressions:
                            expr: _col1
                            type: int
                            expr: _col3
                            type: int
                            expr: _col4
                            type: double
                            expr: _col2
                            type: int
                      outputColumnNames: _col0, _col1, _col2, _col3
                      Select Operator
                        expressions:
                              expr: _col0
                              type: int
                              expr: _col1
                              type: int
                              expr: _col2
                              type: double
                              expr: UDFToDouble(_col3)
                              type: double
                        outputColumnNames: _col0, _col1, _col2, _col3
                        File Output Operator
                          compressed: false
                          GlobalTableId: 1
                          table:
                              input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                              output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
                              serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
                              name: result

  Stage: Stage-4
    Conditional Operator
      list of dependent Tasks:
          Move Operator
            files:
                hdfs directory: true
                destination: hdfs://some-loc
          Map Reduce
            Alias -> Map Operator Tree:
              hdfs://some-loc
                  Reduce Output Operator
                    sort order:
                    Map-reduce partition columns:
                          expr: rand()
                          type: double
                    tag: -1
                    value expressions:
                          expr: cid
                          type: int
                          expr: mid
                          type: int
                          expr: param
                          type: double
                          expr: rating
                          type: double
            Reduce Operator Tree:
              Extract
                File Output Operator
                  compressed: false
                  GlobalTableId: 0
                  table:
                      input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                      output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
                      serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
                      name: result

  Stage: Stage-0
    Move Operator
      tables:
          replace: true
          table:
              input format: org.apache.hadoop.mapred.SequenceFileInputFormat
              output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
              serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
              name: result