Saving all output to "!!{outputDirectory}!!/ppd_repeated_alias.q.raw". Enter "record" with no arguments to stop it. >>> !run !!{qFileDirectory}!!/ppd_repeated_alias.q >>> drop table pokes; No rows affected >>> drop table pokes2; No rows affected >>> create table pokes (foo int, bar int, blah int); No rows affected >>> create table pokes2 (foo int, bar int, blah int); No rows affected >>> >>> -- Q1: predicate should not be pushed on the right side of a left outer join >>> explain SELECT a.foo as foo1, b.foo as foo2, b.bar FROM pokes a LEFT OUTER JOIN pokes2 b ON a.foo=b.foo WHERE b.bar=3; 'Explain' 'ABSTRACT SYNTAX TREE:' ' (TOK_QUERY (TOK_FROM (TOK_LEFTOUTERJOIN (TOK_TABREF (TOK_TABNAME pokes) a) (TOK_TABREF (TOK_TABNAME pokes2) b) (= (. (TOK_TABLE_OR_COL a) foo) (. (TOK_TABLE_OR_COL b) foo)))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL a) foo) foo1) (TOK_SELEXPR (. (TOK_TABLE_OR_COL b) foo) foo2) (TOK_SELEXPR (. (TOK_TABLE_OR_COL b) bar))) (TOK_WHERE (= (. (TOK_TABLE_OR_COL b) bar) 3))))' '' 'STAGE DEPENDENCIES:' ' Stage-1 is a root stage' ' Stage-0 is a root stage' '' 'STAGE PLANS:' ' Stage: Stage-1' ' Map Reduce' ' Alias -> Map Operator Tree:' ' a ' ' TableScan' ' alias: a' ' Reduce Output Operator' ' key expressions:' ' expr: foo' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: foo' ' type: int' ' tag: 0' ' value expressions:' ' expr: foo' ' type: int' ' b ' ' TableScan' ' alias: b' ' Reduce Output Operator' ' key expressions:' ' expr: foo' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: foo' ' type: int' ' tag: 1' ' value expressions:' ' expr: foo' ' type: int' ' expr: bar' ' type: int' ' Reduce Operator Tree:' ' Join Operator' ' condition map:' ' Left Outer Join0 to 1' ' condition expressions:' ' 0 {VALUE._col0}' ' 1 {VALUE._col0} {VALUE._col1}' ' handleSkewJoin: false' ' outputColumnNames: _col0, _col5, _col6' ' Filter Operator' ' predicate:' ' expr: (_col6 = 3)' ' type: boolean' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: _col5' ' type: int' ' expr: _col6' ' type: int' ' outputColumnNames: _col0, _col1, _col2' ' 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' '' '' 77 rows selected >>> >>> -- Q2: predicate should not be pushed on the right side of a left outer join >>> explain SELECT * FROM (SELECT a.foo as foo1, b.foo as foo2, b.bar FROM pokes a LEFT OUTER JOIN pokes2 b ON a.foo=b.foo) a WHERE a.bar=3; 'Explain' 'ABSTRACT SYNTAX TREE:' ' (TOK_QUERY (TOK_FROM (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_LEFTOUTERJOIN (TOK_TABREF (TOK_TABNAME pokes) a) (TOK_TABREF (TOK_TABNAME pokes2) b) (= (. (TOK_TABLE_OR_COL a) foo) (. (TOK_TABLE_OR_COL b) foo)))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL a) foo) foo1) (TOK_SELEXPR (. (TOK_TABLE_OR_COL b) foo) foo2) (TOK_SELEXPR (. (TOK_TABLE_OR_COL b) bar))))) a)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF)) (TOK_WHERE (= (. (TOK_TABLE_OR_COL a) bar) 3))))' '' 'STAGE DEPENDENCIES:' ' Stage-1 is a root stage' ' Stage-0 is a root stage' '' 'STAGE PLANS:' ' Stage: Stage-1' ' Map Reduce' ' Alias -> Map Operator Tree:' ' a:a ' ' TableScan' ' alias: a' ' Reduce Output Operator' ' key expressions:' ' expr: foo' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: foo' ' type: int' ' tag: 0' ' value expressions:' ' expr: foo' ' type: int' ' a:b ' ' TableScan' ' alias: b' ' Reduce Output Operator' ' key expressions:' ' expr: foo' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: foo' ' type: int' ' tag: 1' ' value expressions:' ' expr: foo' ' type: int' ' expr: bar' ' type: int' ' Reduce Operator Tree:' ' Join Operator' ' condition map:' ' Left Outer Join0 to 1' ' condition expressions:' ' 0 {VALUE._col0}' ' 1 {VALUE._col0} {VALUE._col1}' ' handleSkewJoin: false' ' outputColumnNames: _col0, _col5, _col6' ' Filter Operator' ' predicate:' ' expr: (_col6 = 3)' ' type: boolean' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: _col5' ' type: int' ' expr: _col6' ' type: int' ' outputColumnNames: _col0, _col1, _col2' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: _col1' ' type: int' ' expr: _col2' ' type: int' ' outputColumnNames: _col0, _col1, _col2' ' 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' '' '' 86 rows selected >>> >>> -- Q3: predicate should be pushed >>> explain SELECT * FROM (SELECT a.foo as foo1, b.foo as foo2, a.bar FROM pokes a JOIN pokes2 b ON a.foo=b.foo) a WHERE a.bar=3; 'Explain' 'ABSTRACT SYNTAX TREE:' ' (TOK_QUERY (TOK_FROM (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_JOIN (TOK_TABREF (TOK_TABNAME pokes) a) (TOK_TABREF (TOK_TABNAME pokes2) b) (= (. (TOK_TABLE_OR_COL a) foo) (. (TOK_TABLE_OR_COL b) foo)))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL a) foo) foo1) (TOK_SELEXPR (. (TOK_TABLE_OR_COL b) foo) foo2) (TOK_SELEXPR (. (TOK_TABLE_OR_COL a) bar))))) a)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF)) (TOK_WHERE (= (. (TOK_TABLE_OR_COL a) bar) 3))))' '' 'STAGE DEPENDENCIES:' ' Stage-1 is a root stage' ' Stage-0 is a root stage' '' 'STAGE PLANS:' ' Stage: Stage-1' ' Map Reduce' ' Alias -> Map Operator Tree:' ' a:a ' ' TableScan' ' alias: a' ' Filter Operator' ' predicate:' ' expr: (bar = 3)' ' type: boolean' ' Reduce Output Operator' ' key expressions:' ' expr: foo' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: foo' ' type: int' ' tag: 0' ' value expressions:' ' expr: foo' ' type: int' ' expr: bar' ' type: int' ' a:b ' ' TableScan' ' alias: b' ' Reduce Output Operator' ' key expressions:' ' expr: foo' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: foo' ' type: int' ' tag: 1' ' value expressions:' ' expr: foo' ' type: int' ' Reduce Operator Tree:' ' Join Operator' ' condition map:' ' Inner Join 0 to 1' ' condition expressions:' ' 0 {VALUE._col0} {VALUE._col1}' ' 1 {VALUE._col0}' ' handleSkewJoin: false' ' outputColumnNames: _col0, _col1, _col5' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: _col5' ' type: int' ' expr: _col1' ' type: int' ' outputColumnNames: _col0, _col1, _col2' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: _col1' ' type: int' ' expr: _col2' ' type: int' ' outputColumnNames: _col0, _col1, _col2' ' 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' '' '' 86 rows selected >>> >>> -- Q4: here, the filter c.bar should be created under the first join but above the second >>> explain select c.foo, d.bar from (select c.foo, b.bar, c.blah from pokes c left outer join pokes b on c.foo=b.foo) c left outer join pokes d where d.foo=1 and c.bar=2; 'Explain' 'ABSTRACT SYNTAX TREE:' ' (TOK_QUERY (TOK_FROM (TOK_LEFTOUTERJOIN (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_LEFTOUTERJOIN (TOK_TABREF (TOK_TABNAME pokes) c) (TOK_TABREF (TOK_TABNAME pokes) b) (= (. (TOK_TABLE_OR_COL c) foo) (. (TOK_TABLE_OR_COL b) foo)))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL c) foo)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL b) bar)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL c) blah))))) c) (TOK_TABREF (TOK_TABNAME pokes) d))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL c) foo)) (TOK_SELEXPR (. (TOK_TABLE_OR_COL d) bar))) (TOK_WHERE (and (= (. (TOK_TABLE_OR_COL d) foo) 1) (= (. (TOK_TABLE_OR_COL c) bar) 2)))))' '' 'STAGE DEPENDENCIES:' ' Stage-2 is a root stage' ' Stage-1 depends on stages: Stage-2' ' Stage-0 is a root stage' '' 'STAGE PLANS:' ' Stage: Stage-2' ' Map Reduce' ' Alias -> Map Operator Tree:' ' c:b ' ' TableScan' ' alias: b' ' Reduce Output Operator' ' key expressions:' ' expr: foo' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: foo' ' type: int' ' tag: 1' ' value expressions:' ' expr: bar' ' type: int' ' c:c ' ' TableScan' ' alias: c' ' Reduce Output Operator' ' key expressions:' ' expr: foo' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: foo' ' type: int' ' tag: 0' ' value expressions:' ' expr: foo' ' type: int' ' Reduce Operator Tree:' ' Join Operator' ' condition map:' ' Left Outer Join0 to 1' ' condition expressions:' ' 0 {VALUE._col0}' ' 1 {VALUE._col1}' ' handleSkewJoin: false' ' outputColumnNames: _col0, _col6' ' Filter Operator' ' predicate:' ' expr: (_col6 = 2)' ' type: boolean' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: _col6' ' type: int' ' outputColumnNames: _col0, _col1' ' 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' ' sort order: ' ' tag: 0' ' value expressions:' ' expr: _col0' ' type: int' ' expr: _col1' ' type: int' ' d ' ' TableScan' ' alias: d' ' Reduce Output Operator' ' sort order: ' ' tag: 1' ' value expressions:' ' expr: foo' ' type: int' ' expr: bar' ' type: int' ' Reduce Operator Tree:' ' Join Operator' ' condition map:' ' Left Outer Join0 to 1' ' condition expressions:' ' 0 {VALUE._col0} {VALUE._col1}' ' 1 {VALUE._col0} {VALUE._col1}' ' handleSkewJoin: false' ' outputColumnNames: _col0, _col1, _col3, _col4' ' Filter Operator' ' predicate:' ' expr: (_col3 = 1)' ' type: boolean' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: _col4' ' type: int' ' outputColumnNames: _col0, _col1' ' 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' '' '' 124 rows selected >>> >>> drop table pokes; No rows affected >>> drop table pokes2; No rows affected >>> !record