Saving all output to "!!{outputDirectory}!!/index_stale.q.raw". Enter "record" with no arguments to stop it. >>> !run !!{qFileDirectory}!!/index_stale.q >>> -- test that stale indexes are not used >>> >>> 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.filter.compact.minsize=0; No rows affected >>> >>> -- overwrite temp table so index is out of date >>> INSERT OVERWRITE TABLE temp SELECT * FROM src; 'key','value' No rows selected >>> >>> -- should return correct results bypassing index >>> 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-1 is a root stage' ' Stage-0 is a root stage' '' 'STAGE PLANS:' ' 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-0' ' Fetch Operator' ' limit: -1' '' '' 40 rows selected >>> SELECT * FROM temp WHERE key = 86; 'key','val' '86','val_86' 1 row selected >>> DROP table temp; No rows affected >>> !record