Review Board 1.7.22


HIVE-4712: Fix TestCliDriver.truncate_* on 0.23

Review Request #11801 - Created June 11, 2013 and submitted

Brock Noland
trunk
HIVE-4712
Reviewers
hive
ashutoshc
hive-git
Queries just needed and order by to be deterministic.
Passes with both 0.20S and 0.23.
ql/src/test/queries/clientpositive/truncate_column.q
Revision f172bae New Change
1
-- Tests truncating column(s) from a table, also tests that stats are updated
1
-- Tests truncating column(s) from a table, also tests that stats are updated
2

    
   
2

   
3
CREATE TABLE test_tab (key STRING, value STRING) 
3
CREATE TABLE test_tab (key STRING, value STRING) 
4
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe' STORED AS RCFILE;
4
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe' STORED AS RCFILE;
5

    
   
5

   
6
set hive.stats.autogather=true;
6
set hive.stats.autogather=true;
7

    
   
7

   
8
INSERT OVERWRITE TABLE test_tab SELECT * FROM src LIMIT 10;
8
INSERT OVERWRITE TABLE test_tab SELECT * FROM src LIMIT 10;
9

    
   
9

   
10
DESC FORMATTED test_tab;
10
DESC FORMATTED test_tab;
11

    
   
11

   
12
SELECT * FROM test_tab;
12
SELECT * FROM test_tab ORDER BY value;
13

    
   
13

   
14
-- Truncate 1 column
14
-- Truncate 1 column
15
TRUNCATE TABLE test_tab COLUMNS (key);
15
TRUNCATE TABLE test_tab COLUMNS (key);
16

    
   
16

   
17
DESC FORMATTED test_tab;
17
DESC FORMATTED test_tab;
18

    
   
18

   
19
-- First column should be null
19
-- First column should be null
20
SELECT * FROM test_tab;
20
SELECT * FROM test_tab ORDER BY value;
21

    
   
21

   
22
-- Truncate multiple columns
22
-- Truncate multiple columns
23
INSERT OVERWRITE TABLE test_tab SELECT * FROM src LIMIT 10;
23
INSERT OVERWRITE TABLE test_tab SELECT * FROM src LIMIT 10;
24

    
   
24

   
25
TRUNCATE TABLE test_tab COLUMNS (key, value);
25
TRUNCATE TABLE test_tab COLUMNS (key, value);
26

    
   
26

   
27
DESC FORMATTED test_tab;
27
DESC FORMATTED test_tab;
28

    
   
28

   
29
-- Both columns should be null
29
-- Both columns should be null
30
SELECT * FROM test_tab;
30
SELECT * FROM test_tab ORDER BY value;
31

    
   
31

   
32
-- Truncate columns again
32
-- Truncate columns again
33
TRUNCATE TABLE test_tab COLUMNS (key, value);
33
TRUNCATE TABLE test_tab COLUMNS (key, value);
34

    
   
34

   
35
DESC FORMATTED test_tab;
35
DESC FORMATTED test_tab;
36

    
   
36

   
37
-- Both columns should be null
37
-- Both columns should be null
38
SELECT * FROM test_tab;
38
SELECT * FROM test_tab ORDER BY value;
39

    
   
39

   
40
-- Test truncating with a binary serde
40
-- Test truncating with a binary serde
41
ALTER TABLE test_tab SET SERDE 'org.apache.hadoop.hive.serde2.columnar.LazyBinaryColumnarSerDe';
41
ALTER TABLE test_tab SET SERDE 'org.apache.hadoop.hive.serde2.columnar.LazyBinaryColumnarSerDe';
42

    
   
42

   
43
INSERT OVERWRITE TABLE test_tab SELECT * FROM src LIMIT 10;
43
INSERT OVERWRITE TABLE test_tab SELECT * FROM src LIMIT 10;
44

    
   
44

   
45
DESC FORMATTED test_tab;
45
DESC FORMATTED test_tab;
46

    
   
46

   
47
SELECT * FROM test_tab;
47
SELECT * FROM test_tab ORDER BY value;
48

    
   
48

   
49
-- Truncate 1 column
49
-- Truncate 1 column
50
TRUNCATE TABLE test_tab COLUMNS (key);
50
TRUNCATE TABLE test_tab COLUMNS (key);
51

    
   
51

   
52
DESC FORMATTED test_tab;
52
DESC FORMATTED test_tab;
53

    
   
53

   
54
-- First column should be null
54
-- First column should be null
55
SELECT * FROM test_tab;
55
SELECT * FROM test_tab ORDER BY value;
56

    
   
56

   
57
-- Truncate 2 columns
57
-- Truncate 2 columns
58
TRUNCATE TABLE test_tab COLUMNS (key, value);
58
TRUNCATE TABLE test_tab COLUMNS (key, value);
59

    
   
59

   
60
DESC FORMATTED test_tab;
60
DESC FORMATTED test_tab;
61

    
   
61

   
62
-- Both columns should be null
62
-- Both columns should be null
63
SELECT * FROM test_tab;
63
SELECT * FROM test_tab ORDER BY value;
64

    
   
64

   
65
-- Test truncating a partition
65
-- Test truncating a partition
66
CREATE TABLE test_tab_part (key STRING, value STRING) PARTITIONED BY (part STRING) STORED AS RCFILE;
66
CREATE TABLE test_tab_part (key STRING, value STRING) PARTITIONED BY (part STRING) STORED AS RCFILE;
67

    
   
67

   
68
INSERT OVERWRITE TABLE test_tab_part PARTITION (part = '1') SELECT * FROM src LIMIT 10;
68
INSERT OVERWRITE TABLE test_tab_part PARTITION (part = '1') SELECT * FROM src LIMIT 10;
69

    
   
69

   
70
DESC FORMATTED test_tab_part PARTITION (part = '1');
70
DESC FORMATTED test_tab_part PARTITION (part = '1');
71

    
   
71

   
72
SELECT * FROM test_tab_part WHERE part = '1';
72
SELECT * FROM test_tab_part WHERE part = '1' ORDER BY value;
73

    
   
73

   
74
TRUNCATE TABLE test_tab_part PARTITION (part = '1') COLUMNS (key);
74
TRUNCATE TABLE test_tab_part PARTITION (part = '1') COLUMNS (key);
75

    
   
75

   
76
DESC FORMATTED test_tab_part PARTITION (part = '1');
76
DESC FORMATTED test_tab_part PARTITION (part = '1');
77

    
   
77

   
78
-- First column should be null
78
-- First column should be null
79
SELECT * FROM test_tab_part WHERE part = '1';
79
SELECT * FROM test_tab_part WHERE part = '1' ORDER BY value;
ql/src/test/queries/clientpositive/truncate_column_merge.q
Revision 20ef643 New Change
 
ql/src/test/results/clientpositive/truncate_column.q.out
Revision f8af6d0 New Change
 
ql/src/test/results/clientpositive/truncate_column_merge.q.out
Revision 64a917b New Change
 
  1. ql/src/test/queries/clientpositive/truncate_column.q: Loading...
  2. ql/src/test/queries/clientpositive/truncate_column_merge.q: Loading...
  3. ql/src/test/results/clientpositive/truncate_column.q.out: Loading...
  4. ql/src/test/results/clientpositive/truncate_column_merge.q.out: Loading...