Saving all output to "!!{outputDirectory}!!/index_auto_update.q.raw". Enter "record" with no arguments to stop it. >>> !run !!{qFileDirectory}!!/index_auto_update.q >>> -- Test if index is actually being used. >>> >>> -- Create temp, and populate it with some values in src. >>> CREATE TABLE temp(key STRING, val STRING) STORED AS TEXTFILE; No rows affected >>> INSERT OVERWRITE TABLE temp SELECT * FROM src WHERE key < 50; 'key','value' No rows selected >>> >>> -- Build an index on temp. >>> CREATE INDEX temp_index ON TABLE temp(key) as 'COMPACT' WITH DEFERRED REBUILD; No rows affected >>> ALTER INDEX temp_index ON temp REBUILD; No rows affected >>> >>> SET hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat; No rows affected >>> SET hive.optimize.index.filter=true; No rows affected >>> SET hive.optimize.index.autoupdate=true; No rows affected >>> SET hive.optimize.index.filter.compact.minsize=0; No rows affected >>> >>> -- overwrite temp table so index is out of date >>> EXPLAIN INSERT OVERWRITE TABLE temp SELECT * FROM src; 'Explain' 'ABSTRACT SYNTAX TREE:' ' (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME src))) (TOK_INSERT (TOK_DESTINATION (TOK_TAB (TOK_TABNAME temp))) (TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF))))' '' 'STAGE DEPENDENCIES:' ' Stage-4 is a root stage' ' Stage-10 depends on stages: Stage-4 , consists of Stage-7, Stage-6, Stage-8' ' Stage-7' ' Stage-0 depends on stages: Stage-7, Stage-6, Stage-9' ' Stage-1 depends on stages: Stage-0' ' Stage-0 depends on stages: Stage-1' ' Stage-2 depends on stages: Stage-0' ' null depends on stages: Stage-1' ' Stage-3 depends on stages: Stage-1' ' Stage-5 depends on stages: Stage-0' ' Stage-6' ' Stage-8' ' Stage-9 depends on stages: Stage-8' '' 'STAGE PLANS:' ' Stage: Stage-4' ' Map Reduce' ' Alias -> Map Operator Tree:' ' src ' ' TableScan' ' alias: src' ' Select Operator' ' expressions:' ' expr: key' ' type: string' ' expr: value' ' type: string' ' outputColumnNames: _col0, _col1' ' 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: index_auto_update.temp' '' ' Stage: Stage-10' ' Conditional Operator' '' ' Stage: Stage-7' ' Move Operator' ' files:' ' hdfs directory: true' ' destination: pfile:!!{hive.exec.scratchdir}!!' '' ' 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: index_auto_update.temp' '' ' Stage: Stage-1' ' Map Reduce' ' Alias -> Map Operator Tree:' ' temp ' ' TableScan' ' alias: temp' ' Select Operator' ' expressions:' ' expr: key' ' type: string' ' expr: INPUT__FILE__NAME' ' type: string' ' expr: BLOCK__OFFSET__INSIDE__FILE' ' type: bigint' ' outputColumnNames: key, INPUT__FILE__NAME, BLOCK__OFFSET__INSIDE__FILE' ' Group By Operator' ' aggregations:' ' expr: collect_set(BLOCK__OFFSET__INSIDE__FILE)' ' bucketGroup: false' ' keys:' ' expr: key' ' type: string' ' expr: INPUT__FILE__NAME' ' type: string' ' mode: hash' ' outputColumnNames: _col0, _col1, _col2' ' Reduce Output Operator' ' key expressions:' ' expr: _col0' ' type: string' ' expr: _col1' ' type: string' ' sort order: ++' ' Map-reduce partition columns:' ' expr: _col0' ' type: string' ' expr: _col1' ' type: string' ' tag: -1' ' value expressions:' ' expr: _col2' ' type: array' ' Reduce Operator Tree:' ' Group By Operator' ' aggregations:' ' expr: collect_set(VALUE._col0)' ' bucketGroup: false' ' keys:' ' expr: KEY._col0' ' type: string' ' expr: KEY._col1' ' type: string' ' mode: mergepartial' ' outputColumnNames: _col0, _col1, _col2' ' Select Operator' ' expressions:' ' expr: _col0' ' type: string' ' expr: _col1' ' type: string' ' expr: _col2' ' type: array' ' 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: index_auto_update.index_auto_update__temp_temp_index__' '' ' 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: index_auto_update.index_auto_update__temp_temp_index__' '' ' Stage: Stage-2' ' Stats-Aggr Operator' '' ' Stage: null' '' ' Stage: Stage-3' '' ' Stage: Stage-5' ' Stats-Aggr Operator' '' ' Stage: Stage-6' ' Map Reduce' ' Alias -> Map Operator Tree:' ' pfile:!!{hive.exec.scratchdir}!! ' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' 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: index_auto_update.temp' '' ' Stage: Stage-8' ' Map Reduce' ' Alias -> Map Operator Tree:' ' pfile:!!{hive.exec.scratchdir}!! ' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' 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: index_auto_update.temp' '' ' Stage: Stage-9' ' Move Operator' ' files:' ' hdfs directory: true' ' destination: pfile:!!{hive.exec.scratchdir}!!' '' '' 185 rows selected >>> INSERT OVERWRITE TABLE temp SELECT * FROM src; 'key','value' No rows selected >>> >>> -- query should return indexed values >>> EXPLAIN SELECT * FROM temp WHERE key = 86; 'Explain' 'ABSTRACT SYNTAX TREE:' ' (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME temp))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF)) (TOK_WHERE (= (TOK_TABLE_OR_COL key) 86))))' '' 'STAGE DEPENDENCIES:' ' Stage-3 is a root stage' ' Stage-8 depends on stages: Stage-3 , consists of Stage-5, Stage-4, Stage-6' ' Stage-5' ' Stage-2 depends on stages: Stage-5, Stage-4, Stage-7' ' Stage-1 depends on stages: Stage-2' ' Stage-4' ' Stage-6' ' Stage-7 depends on stages: Stage-6' ' Stage-0 is a root stage' '' 'STAGE PLANS:' ' Stage: Stage-3' ' Map Reduce' ' Alias -> Map Operator Tree:' ' index_auto_update__temp_temp_index__ ' ' TableScan' ' alias: index_auto_update__temp_temp_index__' ' filterExpr:' ' expr: (key = 86.0)' ' type: boolean' ' Filter Operator' ' predicate:' ' expr: (key = 86.0)' ' type: boolean' ' Select Operator' ' expressions:' ' expr: _bucketname' ' type: string' ' expr: _offsets' ' type: array' ' outputColumnNames: _col0, _col1' ' File Output Operator' ' compressed: false' ' GlobalTableId: 1' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' '' ' Stage: Stage-8' ' Conditional Operator' '' ' Stage: Stage-5' ' Move Operator' ' files:' ' hdfs directory: true' ' destination: file:!!{hive.exec.scratchdir}!!' '' ' Stage: Stage-2' ' Move Operator' ' files:' ' hdfs directory: true' ' destination: file:!!{hive.exec.scratchdir}!!' '' ' Stage: Stage-1' ' Map Reduce' ' Alias -> Map Operator Tree:' ' temp ' ' TableScan' ' alias: temp' ' filterExpr:' ' expr: (key = 86.0)' ' type: boolean' ' Filter Operator' ' predicate:' ' expr: (key = 86.0)' ' type: boolean' ' Select Operator' ' expressions:' ' expr: key' ' type: string' ' expr: val' ' type: string' ' 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-4' ' Map Reduce' ' Alias -> Map Operator Tree:' ' file:!!{hive.exec.scratchdir}!! ' ' 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-6' ' Map Reduce' ' Alias -> Map Operator Tree:' ' file:!!{hive.exec.scratchdir}!! ' ' 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-7' ' Move Operator' ' files:' ' hdfs directory: true' ' destination: file:!!{hive.exec.scratchdir}!!' '' ' Stage: Stage-0' ' Fetch Operator' ' limit: -1' '' '' 117 rows selected >>> SELECT * FROM temp WHERE key = 86; 'key','val' '86','val_86' 1 row selected >>> >>> SET hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat; No rows affected >>> SET hive.optimize.index.filter=false; No rows affected >>> DROP table temp; No rows affected >>> !record