-
Notifications
You must be signed in to change notification settings - Fork 14
/
HiveDataTypes.md
74 lines (58 loc) · 1.42 KB
/
HiveDataTypes.md
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
65
66
67
68
69
70
71
72
73
74
# Hive Data Types
## Column Types
### Integral Types
Type | Postfix | Example
---|---|---
TINYINT | Y | 10Y
SMALLINT | S | 10S
INT | - | 10
BIGINT | L | 10L
### String Types
Data Type | Length
---|---
VARCHAR | 1 to 65355
CHAR | 255
### Timestamp
It supports `java.sql.Timestamp` format “YYYY-MM-DD HH:MM:SS.fffffffff” and format “yyyy-mm-dd hh:mm:ss.ffffffffff”.
### Dates
DATE values are described in year/month/day format in the form {{YYYY-MM-DD}}.
### Decimals
```
DECIMAL(precision, scale)
decimal(10,0)
```
### Union Types
```
UNIONTYPE<int, double, array<string>, struct<a:int,b:string>>
{0:1}
{1:2.0}
{2:["three","four"]}
{3:{"a":5,"b":"five"}}
{2:["six","seven"]}
{3:{"a":8,"b":"eight"}}
{0:9}
{1:10.0}
```
## Literals
### Floating Point Types
Floating point types are nothing but numbers with decimal points. Generally, this type of data is composed of DOUBLE data type.
### Decimal Type
Decimal type data is nothing but floating point value with higher range than DOUBLE data type.
## Null Value
Missing values are represented by the special value NULL.
## Complex Types
### Arrays
```
Syntax: ARRAY<data_type>
```
### Maps
```
Syntax: MAP<primitive_type, data_type>
```
### Structs
Structs in Hive is similar to using complex data with comment.
```
Syntax: STRUCT<col_name : data_type [COMMENT col_comment], ...>
```
## References
- [Hive - Data Types](https://www.tutorialspoint.com/hive/hive_data_types.htm)