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

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

#
text | 69 lines | 47 code | 22 blank | 0 comment | 0 complexity | 66e83feea6caa1626114a580f5a99359 MD5 | raw file
 1set hive.archive.enabled = true;
 2set hive.enforce.bucketing = true;
 3
 4drop table tstsrc;
 5drop table tstsrcpart;
 6
 7create table tstsrc like src;
 8insert overwrite table tstsrc select key, value from src;
 9
10create table tstsrcpart like srcpart;
11
12insert overwrite table tstsrcpart partition (ds='2008-04-08', hr='11')
13select key, value from srcpart where ds='2008-04-08' and hr='11';
14
15insert overwrite table tstsrcpart partition (ds='2008-04-08', hr='12')
16select key, value from srcpart where ds='2008-04-08' and hr='12';
17
18insert overwrite table tstsrcpart partition (ds='2008-04-09', hr='11')
19select key, value from srcpart where ds='2008-04-09' and hr='11';
20
21insert overwrite table tstsrcpart partition (ds='2008-04-09', hr='12')
22select key, value from srcpart where ds='2008-04-09' and hr='12';
23
24-- EXCLUDE_HADOOP_MAJOR_VERSIONS(0.17, 0.18, 0.19)
25
26SELECT SUM(hash(col)) FROM (SELECT transform(*) using 'tr "\t" "_"' AS col
27FROM (SELECT * FROM tstsrcpart WHERE ds='2008-04-08') subq1) subq2;
28
29ALTER TABLE tstsrcpart ARCHIVE PARTITION (ds='2008-04-08', hr='12');
30
31SELECT SUM(hash(col)) FROM (SELECT transform(*) using 'tr "\t" "_"' AS col
32FROM (SELECT * FROM tstsrcpart WHERE ds='2008-04-08') subq1) subq2;
33
34SELECT key, count(1) FROM tstsrcpart WHERE ds='2008-04-08' AND hr='12' AND key='0' GROUP BY key;
35
36SELECT * FROM tstsrcpart a JOIN tstsrc b ON a.key=b.key
37WHERE a.ds='2008-04-08' AND a.hr='12' AND a.key='0';
38
39ALTER TABLE tstsrcpart UNARCHIVE PARTITION (ds='2008-04-08', hr='12');
40
41SELECT SUM(hash(col)) FROM (SELECT transform(*) using 'tr "\t" "_"' AS col
42FROM (SELECT * FROM tstsrcpart WHERE ds='2008-04-08') subq1) subq2;
43
44CREATE TABLE harbucket(key INT)
45PARTITIONED by (ds STRING)
46CLUSTERED BY (key) INTO 10 BUCKETS;
47
48INSERT OVERWRITE TABLE harbucket PARTITION(ds='1') SELECT CAST(key AS INT) AS a FROM tstsrc WHERE key < 50;
49
50SELECT key FROM harbucket TABLESAMPLE(BUCKET 1 OUT OF 10) SORT BY key;
51ALTER TABLE tstsrcpart ARCHIVE PARTITION (ds='2008-04-08', hr='12');
52SELECT key FROM harbucket TABLESAMPLE(BUCKET 1 OUT OF 10) SORT BY key;
53ALTER TABLE tstsrcpart UNARCHIVE PARTITION (ds='2008-04-08', hr='12');
54SELECT key FROM harbucket TABLESAMPLE(BUCKET 1 OUT OF 10) SORT BY key;
55
56
57CREATE TABLE old_name(key INT)
58PARTITIONED by (ds STRING);
59
60INSERT OVERWRITE TABLE old_name PARTITION(ds='1') SELECT CAST(key AS INT) AS a FROM tstsrc WHERE key < 50;
61ALTER TABLE old_name ARCHIVE PARTITION (ds='1');
62SELECT SUM(hash(col)) FROM (SELECT transform(*) using 'tr "\t" "_"' AS col
63FROM (SELECT * FROM old_name WHERE ds='1') subq1) subq2;
64ALTER TABLE old_name RENAME TO new_name;
65SELECT SUM(hash(col)) FROM (SELECT transform(*) using 'tr "\t" "_"' AS col
66FROM (SELECT * FROM new_name WHERE ds='1') subq1) subq2;
67
68drop table tstsrc;
69drop table tstsrcpart;