Saving all output to "!!{outputDirectory}!!/groupby10.q.raw". Enter "record" with no arguments to stop it. >>> !run !!{qFileDirectory}!!/groupby10.q >>> set hive.map.aggr=false; No rows affected >>> set hive.multigroupby.singlereducer=false; No rows affected >>> set hive.groupby.skewindata=true; No rows affected >>> >>> CREATE TABLE dest1(key INT, val1 INT, val2 INT); No rows affected >>> CREATE TABLE dest2(key INT, val1 INT, val2 INT); No rows affected >>> >>> CREATE TABLE INPUT(key INT, value STRING) STORED AS TEXTFILE; No rows affected >>> LOAD DATA LOCAL INPATH '../data/files/kv5.txt' INTO TABLE INPUT; No rows affected >>> >>> EXPLAIN FROM INPUT INSERT OVERWRITE TABLE dest1 SELECT INPUT.key, count(substr(INPUT.value,5)), count(distinct substr(INPUT.value,5)) GROUP BY INPUT.key INSERT OVERWRITE TABLE dest2 SELECT INPUT.key, sum(substr(INPUT.value,5)), sum(distinct substr(INPUT.value,5)) GROUP BY INPUT.key; 'Explain' 'ABSTRACT SYNTAX TREE:' ' (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME INPUT))) (TOK_INSERT (TOK_DESTINATION (TOK_TAB (TOK_TABNAME dest1))) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL INPUT) key)) (TOK_SELEXPR (TOK_FUNCTION count (TOK_FUNCTION substr (. (TOK_TABLE_OR_COL INPUT) value) 5))) (TOK_SELEXPR (TOK_FUNCTIONDI count (TOK_FUNCTION substr (. (TOK_TABLE_OR_COL INPUT) value) 5)))) (TOK_GROUPBY (. (TOK_TABLE_OR_COL INPUT) key))) (TOK_INSERT (TOK_DESTINATION (TOK_TAB (TOK_TABNAME dest2))) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL INPUT) key)) (TOK_SELEXPR (TOK_FUNCTION sum (TOK_FUNCTION substr (. (TOK_TABLE_OR_COL INPUT) value) 5))) (TOK_SELEXPR (TOK_FUNCTIONDI sum (TOK_FUNCTION substr (. (TOK_TABLE_OR_COL INPUT) value) 5)))) (TOK_GROUPBY (. (TOK_TABLE_OR_COL INPUT) key))))' '' 'STAGE DEPENDENCIES:' ' Stage-2 is a root stage' ' Stage-3 depends on stages: Stage-2' ' Stage-0 depends on stages: Stage-3' ' Stage-4 depends on stages: Stage-0' ' Stage-5 depends on stages: Stage-2' ' Stage-1 depends on stages: Stage-5' ' Stage-6 depends on stages: Stage-1' '' 'STAGE PLANS:' ' Stage: Stage-2' ' Map Reduce' ' Alias -> Map Operator Tree:' ' input ' ' TableScan' ' alias: input' ' Reduce Output Operator' ' key expressions:' ' expr: substr(value, 5)' ' type: string' ' sort order: +' ' Map-reduce partition columns:' ' expr: substr(value, 5)' ' type: string' ' tag: -1' ' value expressions:' ' expr: key' ' type: int' ' Reduce Operator Tree:' ' Forward' ' Group By Operator' ' aggregations:' ' expr: count(KEY._col0)' ' expr: count(DISTINCT KEY._col0)' ' bucketGroup: false' ' keys:' ' expr: VALUE._col0' ' type: int' ' mode: hash' ' outputColumnNames: _col0, _col1, _col2' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.SequenceFileInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat' ' Group By Operator' ' aggregations:' ' expr: sum(KEY._col0)' ' expr: sum(DISTINCT KEY._col0)' ' bucketGroup: false' ' keys:' ' expr: VALUE._col0' ' type: int' ' mode: hash' ' outputColumnNames: _col0, _col1, _col2' ' 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:' ' file:!!{hive.exec.scratchdir}!! ' ' Reduce Output Operator' ' key expressions:' ' expr: _col0' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: _col0' ' type: int' ' tag: -1' ' value expressions:' ' expr: _col1' ' type: bigint' ' expr: _col2' ' type: bigint' ' Reduce Operator Tree:' ' Group By Operator' ' aggregations:' ' expr: count(VALUE._col0)' ' expr: count(VALUE._col1)' ' bucketGroup: false' ' keys:' ' expr: KEY._col0' ' type: int' ' mode: final' ' outputColumnNames: _col0, _col1, _col2' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: _col1' ' type: bigint' ' expr: _col2' ' type: bigint' ' outputColumnNames: _col0, _col1, _col2' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: UDFToInteger(_col1)' ' type: int' ' expr: UDFToInteger(_col2)' ' type: int' ' outputColumnNames: _col0, _col1, _col2' ' File Output Operator' ' compressed: false' ' GlobalTableId: 1' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' ' serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' ' name: groupby10.dest1' '' ' Stage: Stage-0' ' Move Operator' ' tables:' ' replace: true' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' ' serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' ' name: groupby10.dest1' '' ' Stage: Stage-4' ' Stats-Aggr Operator' '' ' Stage: Stage-5' ' Map Reduce' ' Alias -> Map Operator Tree:' ' file:!!{hive.exec.scratchdir}!! ' ' Reduce Output Operator' ' key expressions:' ' expr: _col0' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: _col0' ' type: int' ' tag: -1' ' value expressions:' ' expr: _col1' ' type: double' ' expr: _col2' ' type: double' ' Reduce Operator Tree:' ' Group By Operator' ' aggregations:' ' expr: sum(VALUE._col0)' ' expr: sum(VALUE._col1)' ' bucketGroup: false' ' keys:' ' expr: KEY._col0' ' type: int' ' mode: final' ' outputColumnNames: _col0, _col1, _col2' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: _col1' ' type: double' ' expr: _col2' ' type: double' ' outputColumnNames: _col0, _col1, _col2' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: UDFToInteger(_col1)' ' type: int' ' expr: UDFToInteger(_col2)' ' type: int' ' outputColumnNames: _col0, _col1, _col2' ' File Output Operator' ' compressed: false' ' GlobalTableId: 2' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' ' serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' ' name: groupby10.dest2' '' ' Stage: Stage-1' ' Move Operator' ' tables:' ' replace: true' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' ' serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' ' name: groupby10.dest2' '' ' Stage: Stage-6' ' Stats-Aggr Operator' '' '' 205 rows selected >>> >>> FROM INPUT INSERT OVERWRITE TABLE dest1 SELECT INPUT.key, count(substr(INPUT.value,5)), count(distinct substr(INPUT.value,5)) GROUP BY INPUT.key INSERT OVERWRITE TABLE dest2 SELECT INPUT.key, sum(substr(INPUT.value,5)), sum(distinct substr(INPUT.value,5)) GROUP BY INPUT.key; '_col0','_col1','_col2' No rows selected >>> >>> SELECT * from dest1; 'key','val1','val2' '27','1','1' '66','1','1' '86','1','1' '98','1','1' '128','1','1' '150','1','1' '165','1','1' '193','1','1' '213','3','2' '224','1','1' '238','3','3' '255','1','1' '265','1','1' '273','1','1' '278','1','1' '311','1','1' '369','1','1' '401','1','1' '409','1','1' '484','1','1' 20 rows selected >>> SELECT * from dest2; 'key','val1','val2' '27','27','27' '66','66','66' '86','86','86' '98','98','98' '128','128','128' '150','150','150' '165','165','165' '193','193','193' '213','640','427' '224','224','224' '238','717','717' '255','255','255' '265','265','265' '273','273','273' '278','278','278' '311','311','311' '369','369','369' '401','401','401' '409','409','409' '484','484','484' 20 rows selected >>> >>> set hive.multigroupby.singlereducer=true; No rows affected >>> >>> EXPLAIN FROM INPUT INSERT OVERWRITE TABLE dest1 SELECT INPUT.key, count(substr(INPUT.value,5)), count(distinct substr(INPUT.value,5)) GROUP BY INPUT.key INSERT OVERWRITE TABLE dest2 SELECT INPUT.key, sum(substr(INPUT.value,5)), sum(distinct substr(INPUT.value,5)) GROUP BY INPUT.key; 'Explain' 'ABSTRACT SYNTAX TREE:' ' (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME INPUT))) (TOK_INSERT (TOK_DESTINATION (TOK_TAB (TOK_TABNAME dest1))) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL INPUT) key)) (TOK_SELEXPR (TOK_FUNCTION count (TOK_FUNCTION substr (. (TOK_TABLE_OR_COL INPUT) value) 5))) (TOK_SELEXPR (TOK_FUNCTIONDI count (TOK_FUNCTION substr (. (TOK_TABLE_OR_COL INPUT) value) 5)))) (TOK_GROUPBY (. (TOK_TABLE_OR_COL INPUT) key))) (TOK_INSERT (TOK_DESTINATION (TOK_TAB (TOK_TABNAME dest2))) (TOK_SELECT (TOK_SELEXPR (. (TOK_TABLE_OR_COL INPUT) key)) (TOK_SELEXPR (TOK_FUNCTION sum (TOK_FUNCTION substr (. (TOK_TABLE_OR_COL INPUT) value) 5))) (TOK_SELEXPR (TOK_FUNCTIONDI sum (TOK_FUNCTION substr (. (TOK_TABLE_OR_COL INPUT) value) 5)))) (TOK_GROUPBY (. (TOK_TABLE_OR_COL INPUT) key))))' '' 'STAGE DEPENDENCIES:' ' Stage-2 is a root stage' ' Stage-3 depends on stages: Stage-2' ' Stage-0 depends on stages: Stage-3' ' Stage-4 depends on stages: Stage-0' ' Stage-5 depends on stages: Stage-2' ' Stage-1 depends on stages: Stage-5' ' Stage-6 depends on stages: Stage-1' '' 'STAGE PLANS:' ' Stage: Stage-2' ' Map Reduce' ' Alias -> Map Operator Tree:' ' input ' ' TableScan' ' alias: input' ' Reduce Output Operator' ' key expressions:' ' expr: substr(value, 5)' ' type: string' ' sort order: +' ' Map-reduce partition columns:' ' expr: substr(value, 5)' ' type: string' ' tag: -1' ' value expressions:' ' expr: key' ' type: int' ' Reduce Operator Tree:' ' Forward' ' Group By Operator' ' aggregations:' ' expr: count(KEY._col0)' ' expr: count(DISTINCT KEY._col0)' ' bucketGroup: false' ' keys:' ' expr: VALUE._col0' ' type: int' ' mode: hash' ' outputColumnNames: _col0, _col1, _col2' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.SequenceFileInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat' ' Group By Operator' ' aggregations:' ' expr: sum(KEY._col0)' ' expr: sum(DISTINCT KEY._col0)' ' bucketGroup: false' ' keys:' ' expr: VALUE._col0' ' type: int' ' mode: hash' ' outputColumnNames: _col0, _col1, _col2' ' 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:' ' file:!!{hive.exec.scratchdir}!! ' ' Reduce Output Operator' ' key expressions:' ' expr: _col0' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: _col0' ' type: int' ' tag: -1' ' value expressions:' ' expr: _col1' ' type: bigint' ' expr: _col2' ' type: bigint' ' Reduce Operator Tree:' ' Group By Operator' ' aggregations:' ' expr: count(VALUE._col0)' ' expr: count(VALUE._col1)' ' bucketGroup: false' ' keys:' ' expr: KEY._col0' ' type: int' ' mode: final' ' outputColumnNames: _col0, _col1, _col2' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: _col1' ' type: bigint' ' expr: _col2' ' type: bigint' ' outputColumnNames: _col0, _col1, _col2' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: UDFToInteger(_col1)' ' type: int' ' expr: UDFToInteger(_col2)' ' type: int' ' outputColumnNames: _col0, _col1, _col2' ' File Output Operator' ' compressed: false' ' GlobalTableId: 1' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' ' serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' ' name: groupby10.dest1' '' ' Stage: Stage-0' ' Move Operator' ' tables:' ' replace: true' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' ' serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' ' name: groupby10.dest1' '' ' Stage: Stage-4' ' Stats-Aggr Operator' '' ' Stage: Stage-5' ' Map Reduce' ' Alias -> Map Operator Tree:' ' file:!!{hive.exec.scratchdir}!! ' ' Reduce Output Operator' ' key expressions:' ' expr: _col0' ' type: int' ' sort order: +' ' Map-reduce partition columns:' ' expr: _col0' ' type: int' ' tag: -1' ' value expressions:' ' expr: _col1' ' type: double' ' expr: _col2' ' type: double' ' Reduce Operator Tree:' ' Group By Operator' ' aggregations:' ' expr: sum(VALUE._col0)' ' expr: sum(VALUE._col1)' ' bucketGroup: false' ' keys:' ' expr: KEY._col0' ' type: int' ' mode: final' ' outputColumnNames: _col0, _col1, _col2' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: _col1' ' type: double' ' expr: _col2' ' type: double' ' outputColumnNames: _col0, _col1, _col2' ' Select Operator' ' expressions:' ' expr: _col0' ' type: int' ' expr: UDFToInteger(_col1)' ' type: int' ' expr: UDFToInteger(_col2)' ' type: int' ' outputColumnNames: _col0, _col1, _col2' ' File Output Operator' ' compressed: false' ' GlobalTableId: 2' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' ' serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' ' name: groupby10.dest2' '' ' Stage: Stage-1' ' Move Operator' ' tables:' ' replace: true' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' ' serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' ' name: groupby10.dest2' '' ' Stage: Stage-6' ' Stats-Aggr Operator' '' '' 205 rows selected >>> >>> FROM INPUT INSERT OVERWRITE TABLE dest1 SELECT INPUT.key, count(substr(INPUT.value,5)), count(distinct substr(INPUT.value,5)) GROUP BY INPUT.key INSERT OVERWRITE TABLE dest2 SELECT INPUT.key, sum(substr(INPUT.value,5)), sum(distinct substr(INPUT.value,5)) GROUP BY INPUT.key; '_col0','_col1','_col2' No rows selected >>> >>> SELECT * from dest1; 'key','val1','val2' '27','1','1' '66','1','1' '86','1','1' '98','1','1' '128','1','1' '150','1','1' '165','1','1' '193','1','1' '213','3','2' '224','1','1' '238','3','3' '255','1','1' '265','1','1' '273','1','1' '278','1','1' '311','1','1' '369','1','1' '401','1','1' '409','1','1' '484','1','1' 20 rows selected >>> SELECT * from dest2; 'key','val1','val2' '27','27','27' '66','66','66' '86','86','86' '98','98','98' '128','128','128' '150','150','150' '165','165','165' '193','193','193' '213','640','427' '224','224','224' '238','717','717' '255','255','255' '265','265','265' '273','273','273' '278','278','278' '311','311','311' '369','369','369' '401','401','401' '409','409','409' '484','484','484' 20 rows selected >>> !record