CREATE TABLE triples (foo string, subject string, predicate string, object string, foo2 string)


EXPLAIN
SELECT t11.subject, t22.object , t33.subject , t55.object, t66.object
FROM
(
SELECT t1.subject
FROM triples t1
WHERE
t1.predicate='http://sofa.semanticweb.org/sofa/v1.0/system#__INSTANCEOF_REL'
AND
t1.object='http://ontos/OntosMiner/Common.English/ontology#Citation'
) t11
JOIN
(
SELECT t2.subject , t2.object
FROM triples t2
WHERE
t2.predicate='http://sofa.semanticweb.org/sofa/v1.0/system#__LABEL_REL'
) t22
ON (t11.subject=t22.subject)
JOIN
(
SELECT t3.subject , t3.object
FROM triples t3
WHERE
t3.predicate='http://www.ontosearch.com/2007/12/ontosofa-ns#_from'

) t33
ON (t11.subject=t33.object)
JOIN
(
SELECT t4.subject
FROM triples t4
WHERE
t4.predicate='http://sofa.semanticweb.org/sofa/v1.0/system#__INSTANCEOF_REL'
AND
t4.object='http://ontos/OntosMiner/Common.English/ontology#Author'

) t44
ON (t44.subject=t33.subject)
JOIN
(
SELECT t5.subject, t5.object
FROM triples t5
WHERE
t5.predicate='http://www.ontosearch.com/2007/12/ontosofa-ns#_to'
) t55
ON (t55.subject=t44.subject)
JOIN
(
SELECT t6.subject, t6.object
FROM triples t6
WHERE
t6.predicate='http://sofa.semanticweb.org/sofa/v1.0/system#__LABEL_REL'
) t66
ON (t66.subject=t55.object)
ABSTRACT SYNTAX TREE:
  (TOK_QUERY (TOK_FROM (TOK_JOIN (TOK_JOIN (TOK_JOIN (TOK_JOIN (TOK_JOIN (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME triples) t1)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL t1) subject))) (TOK_WHERE (AND (= (. (TOK_TABLE_OR_COL t1) predicate) 'http://sofa.semanticweb.org/sofa/v1.0/system#__INSTANCEOF_REL') (= (. (TOK_TABLE_OR_COL t1) object) 'http://ontos/OntosMiner/Common.English/ontology#Citation'))))) t11) (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME triples) t2)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL t2) subject)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL t2) object))) (TOK_WHERE (= (. (TOK_TABLE_OR_COL t2) predicate) 'http://sofa.semanticweb.org/sofa/v1.0/system#__LABEL_REL')))) t22) (= (. (TOK_TABLE_OR_COL t11) subject) (. (TOK_TABLE_OR_COL t22) subject))) (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME triples) t3)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL t3) subject)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL t3) object))) (TOK_WHERE (= (. (TOK_TABLE_OR_COL t3) predicate) 'http://www.ontosearch.com/2007/12/ontosofa-ns#_from')))) t33) (= (. (TOK_TABLE_OR_COL t11) subject) (. (TOK_TABLE_OR_COL t33) object))) (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME triples) t4)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL t4) subject))) (TOK_WHERE (AND (= (. (TOK_TABLE_OR_COL t4) predicate) 'http://sofa.semanticweb.org/sofa/v1.0/system#__INSTANCEOF_REL') (= (. (TOK_TABLE_OR_COL t4) object) 'http://ontos/OntosMiner/Common.English/ontology#Author'))))) t44) (= (. (TOK_TABLE_OR_COL t44) subject) (. (TOK_TABLE_OR_COL t33) subject))) (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME triples) t5)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL t5) subject)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL t5) object))) (TOK_WHERE (= (. (TOK_TABLE_OR_COL t5) predicate) 'http://www.ontosearch.com/2007/12/ontosofa-ns#_to')))) t55) (= (. (TOK_TABLE_OR_COL t55) subject) (. (TOK_TABLE_OR_COL t44) subject))) (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME triples) t6)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL t6) subject)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL t6) object))) (TOK_WHERE (= (. (TOK_TABLE_OR_COL t6) predicate) 'http://sofa.semanticweb.org/sofa/v1.0/system#__LABEL_REL')))) t66) (= (. (TOK_TABLE_OR_COL t66) subject) (. (TOK_TABLE_OR_COL t55) object)))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL t11) subject)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL t22) object)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL t33) subject)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL t55) object)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL t66) object)))))

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

STAGE PLANS:
  Stage: Stage-2
    Map Reduce
      Alias -> Map Operator Tree:
        t11:t1 
          TableScan
            alias: t1
            Filter Operator
              predicate:
                  expr: ((predicate = 'http://sofa.semanticweb.org/sofa/v1.0/system#__INSTANCEOF_REL') and (object = 'http://ontos/OntosMiner/Common.English/ontology#Citation'))
                  type: boolean
              Select Operator
                expressions:
                      expr: subject
                      type: string
                outputColumnNames: _col0
                Reduce Output Operator
                  key expressions:
                        expr: _col0
                        type: string
                  sort order: +
                  Map-reduce partition columns:
                        expr: _col0
                        type: string
                  tag: 0
                  value expressions:
                        expr: _col0
                        type: string
        t22:t2 
          TableScan
            alias: t2
            Filter Operator
              predicate:
                  expr: (predicate = 'http://sofa.semanticweb.org/sofa/v1.0/system#__LABEL_REL')
                  type: boolean
              Select Operator
                expressions:
                      expr: subject
                      type: string
                      expr: object
                      type: string
                outputColumnNames: _col0, _col1
                Reduce Output Operator
                  key expressions:
                        expr: _col0
                        type: string
                  sort order: +
                  Map-reduce partition columns:
                        expr: _col0
                        type: string
                  tag: 1
                  value expressions:
                        expr: _col1
                        type: string
        t33:t3 
          TableScan
            alias: t3
            Filter Operator
              predicate:
                  expr: (predicate = 'http://www.ontosearch.com/2007/12/ontosofa-ns#_from')
                  type: boolean
              Select Operator
                expressions:
                      expr: subject
                      type: string
                      expr: object
                      type: string
                outputColumnNames: _col0, _col1
                Reduce Output Operator
                  key expressions:
                        expr: _col1
                        type: string
                  sort order: +
                  Map-reduce partition columns:
                        expr: _col1
                        type: string
                  tag: 2
                  value expressions:
                        expr: _col0
                        type: string
      Reduce Operator Tree:
        Join Operator
          condition map:
               Inner Join 0 to 1
               Inner Join 0 to 2
          condition expressions:
            0 {VALUE._col0}
            1 {VALUE._col1}
            2 {VALUE._col0}
          handleSkewJoin: false
          outputColumnNames: _col0, _col2, _col3
          File Output Operator
            compressed: false
            GlobalTableId: 0
            table:
                input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat

  Stage: Stage-3
    Map Reduce
      Alias -> Map Operator Tree:
        $INTNAME 
            Reduce Output Operator
              key expressions:
                    expr: _col3
                    type: string
              sort order: +
              Map-reduce partition columns:
                    expr: _col3
                    type: string
              tag: 0
              value expressions:
                    expr: _col3
                    type: string
                    expr: _col0
                    type: string
                    expr: _col2
                    type: string
        t44:t4 
          TableScan
            alias: t4
            Filter Operator
              predicate:
                  expr: ((predicate = 'http://sofa.semanticweb.org/sofa/v1.0/system#__INSTANCEOF_REL') and (object = 'http://ontos/OntosMiner/Common.English/ontology#Author'))
                  type: boolean
              Select Operator
                expressions:
                      expr: subject
                      type: string
                outputColumnNames: _col0
                Reduce Output Operator
                  key expressions:
                        expr: _col0
                        type: string
                  sort order: +
                  Map-reduce partition columns:
                        expr: _col0
                        type: string
                  tag: 1
        t55:t5 
          TableScan
            alias: t5
            Filter Operator
              predicate:
                  expr: (predicate = 'http://www.ontosearch.com/2007/12/ontosofa-ns#_to')
                  type: boolean
              Select Operator
                expressions:
                      expr: subject
                      type: string
                      expr: object
                      type: string
                outputColumnNames: _col0, _col1
                Reduce Output Operator
                  key expressions:
                        expr: _col0
                        type: string
                  sort order: +
                  Map-reduce partition columns:
                        expr: _col0
                        type: string
                  tag: 2
                  value expressions:
                        expr: _col1
                        type: string
      Reduce Operator Tree:
        Join Operator
          condition map:
               Inner Join 0 to 1
               Inner Join 1 to 2
          condition expressions:
            0 {VALUE._col0} {VALUE._col2} {VALUE._col4}
            1 
            2 {VALUE._col1}
          handleSkewJoin: false
          outputColumnNames: _col0, _col2, _col4, _col7
          File Output Operator
            compressed: false
            GlobalTableId: 0
            table:
                input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat

  Stage: Stage-1
    Map Reduce
      Alias -> Map Operator Tree:
        $INTNAME 
            Reduce Output Operator
              key expressions:
                    expr: _col7
                    type: string
              sort order: +
              Map-reduce partition columns:
                    expr: _col7
                    type: string
              tag: 0
              value expressions:
                    expr: _col0
                    type: string
                    expr: _col2
                    type: string
                    expr: _col4
                    type: string
                    expr: _col7
                    type: string
        t66:t6 
          TableScan
            alias: t6
            Filter Operator
              predicate:
                  expr: (predicate = 'http://sofa.semanticweb.org/sofa/v1.0/system#__LABEL_REL')
                  type: boolean
              Select Operator
                expressions:
                      expr: subject
                      type: string
                      expr: object
                      type: string
                outputColumnNames: _col0, _col1
                Reduce Output Operator
                  key expressions:
                        expr: _col0
                        type: string
                  sort order: +
                  Map-reduce partition columns:
                        expr: _col0
                        type: string
                  tag: 1
                  value expressions:
                        expr: _col1
                        type: string
      Reduce Operator Tree:
        Join Operator
          condition map:
               Inner Join 0 to 1
          condition expressions:
            0 {VALUE._col0} {VALUE._col3} {VALUE._col5} {VALUE._col7}
            1 {VALUE._col1}
          handleSkewJoin: false
          outputColumnNames: _col0, _col3, _col5, _col7, _col9
          Select Operator
            expressions:
                  expr: _col3
                  type: string
                  expr: _col5
                  type: string
                  expr: _col0
                  type: string
                  expr: _col7
                  type: string
                  expr: _col9
                  type: string
            outputColumnNames: _col0, _col1, _col2, _col3, _col4
            File Output Operator
              compressed: false
              GlobalTableId: 0
              table:
                  input format: org.apache.hadoop.mapred.TextInputFormat
                  output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat

  Stage: Stage-0
    Fetch Operator
      limit: -1


