PageRenderTime 9ms CodeModel.GetById 6ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/release-0.0.0-rc0/hive/external/ql/src/test/queries/clientpositive/index_compact_2.q

#
text | 45 lines | 35 code | 10 blank | 0 comment | 0 complexity | 18a120d397e8ff83ecb6b80b33df5a02 MD5 | raw file
 1CREATE TABLE srcpart_rc (key int, value string) PARTITIONED BY (ds string, hr int) STORED AS RCFILE;
 2
 3INSERT OVERWRITE TABLE srcpart_rc PARTITION (ds='2008-04-08', hr=11) SELECT key, value FROM srcpart WHERE ds = '2008-04-08' AND hr = 11;
 4INSERT OVERWRITE TABLE srcpart_rc PARTITION (ds='2008-04-08', hr=12) SELECT key, value FROM srcpart WHERE ds = '2008-04-08' AND hr = 12;
 5INSERT OVERWRITE TABLE srcpart_rc PARTITION (ds='2008-04-09', hr=11) SELECT key, value FROM srcpart WHERE ds = '2008-04-09' AND hr = 11;
 6INSERT OVERWRITE TABLE srcpart_rc PARTITION (ds='2008-04-09', hr=12) SELECT key, value FROM srcpart WHERE ds = '2008-04-09' AND hr = 12;
 7
 8CREATE INDEX srcpart_rc_index ON TABLE srcpart_rc(key) as 'COMPACT' WITH DEFERRED REBUILD;
 9ALTER INDEX srcpart_rc_index ON srcpart_rc REBUILD;
10SELECT x.* FROM default__srcpart_rc_srcpart_rc_index__ x WHERE x.ds = '2008-04-08' and x.hr = 11 ORDER BY key;
11
12SET hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
13INSERT OVERWRITE DIRECTORY "/tmp/index_test_index_result" SELECT `_bucketname` ,  `_offsets` FROM default__srcpart_rc_srcpart_rc_index__ x WHERE x.key=100 AND x.ds = '2008-04-08';
14SET hive.index.compact.file=/tmp/index_test_index_result;
15SET hive.input.format=org.apache.hadoop.hive.ql.index.compact.HiveCompactIndexInputFormat;
16SELECT key, value FROM srcpart_rc WHERE key=100 AND ds = '2008-04-08' ORDER BY key;
17
18SET hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
19INSERT OVERWRITE DIRECTORY "/tmp/index_test_index_result" SELECT `_bucketname` ,  `_offsets` FROM default__srcpart_rc_srcpart_rc_index__ x WHERE x.key=100 AND x.ds = '2008-04-08' and x.hr = 11;
20SET hive.index.compact.file=/tmp/index_test_index_result;
21SET hive.input.format=org.apache.hadoop.hive.ql.index.compact.HiveCompactIndexInputFormat;
22SELECT key, value FROM srcpart_rc WHERE key=100 AND ds = '2008-04-08' and hr = 11 ORDER BY key;
23
24SET hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
25SELECT key, value FROM srcpart_rc WHERE key=100 AND ds = '2008-04-08' and hr = 11 ORDER BY key;
26
27DROP INDEX srcpart_rc_index on srcpart_rc;
28
29EXPLAIN
30CREATE INDEX srcpart_rc_index ON TABLE srcpart_rc(key) as 'COMPACT' WITH DEFERRED REBUILD;
31CREATE INDEX srcpart_rc_index ON TABLE srcpart_rc(key) as 'COMPACT' WITH DEFERRED REBUILD;
32ALTER  INDEX srcpart_rc_index ON srcpart_rc REBUILD;
33SELECT x.* FROM default__srcpart_rc_srcpart_rc_index__ x ORDER BY key;
34
35SET hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
36INSERT OVERWRITE DIRECTORY "/tmp/index_result" SELECT `_bucketname` ,  `_offsets` FROM default__srcpart_rc_srcpart_rc_index__ WHERE key=100;
37SET hive.index.compact.file=/tmp/index_result;
38SET hive.input.format=org.apache.hadoop.hive.ql.index.compact.HiveCompactIndexInputFormat;
39SELECT key, value FROM srcpart_rc WHERE key=100 ORDER BY key;
40
41SET hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
42SELECT key, value FROM srcpart_rc WHERE key=100 ORDER BY key;
43
44DROP INDEX srcpart_rc_index on srcpart_rc;
45DROP TABLE srcpart_rc;