-
Notifications
You must be signed in to change notification settings - Fork 937
/
Copy pathmake_one_row_complex.sh
executable file
·64 lines (61 loc) · 1.35 KB
/
make_one_row_complex.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash -eux
COLUMNS='
`boolean` BOOLEAN,
`tinyint` TINYINT,
`smallint` SMALLINT,
`int` INT,
`bigint` BIGINT,
`float` FLOAT,
`double` DOUBLE,
`string` STRING,
`timestamp` TIMESTAMP,
`binary` BINARY,
`array` ARRAY<int>,
`map` MAP<int, int>,
`struct` STRUCT<a: int, b: int>,
`union` UNIONTYPE<int, string>,
`decimal` DECIMAL(10, 1)
'
hive -e "
set mapred.job.tracker=local;
DROP TABLE IF EXISTS one_row_complex;
DROP TABLE IF EXISTS one_row_complex_null;
CREATE TABLE one_row_complex ($COLUMNS);
CREATE TABLE one_row_complex_null ($COLUMNS);
INSERT OVERWRITE TABLE one_row_complex SELECT
true,
127,
32767,
2147483647,
9223372036854775807,
0.5,
0.25,
'a string',
0,
'123',
array(1, 2),
map(1, 2, 3, 4),
named_struct('a', 1, 'b', 2),
create_union(0, 1, 'test_string'),
0.1
FROM one_row;
INSERT OVERWRITE TABLE one_row_complex_null SELECT
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
IF(false, array(1, 2), null),
IF(false, map(1, 2, 3, 4), null),
IF(false, named_struct('a', 1, 'b', 2), null),
IF(false, create_union(0, 1, 'test_string'), null),
null
FROM one_row;
"
# Note: using IF(false, ...) above to work around https://issues.apache.org/jira/browse/HIVE-4022
# The problem is that a "void" type cannot be inserted into a complex type field.