hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Hadoop Wiki] Trivial Update of "Hive/HiveQL/Types" by ZhengShao
Date Wed, 21 Jan 2009 22:57:39 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Hadoop Wiki" for change notification.

The following page has been changed by ZhengShao:
http://wiki.apache.org/hadoop/Hive/HiveQL/Types

------------------------------------------------------------------------------
  == Types supported By Hive ==
- The following types are supported by Hive:
+ Types are associated with the columns in the tables. Hive supports 2 sets of types: primitive
types and complex types.
+ 
+ === Primitive Types ===
-  * !TinyInt: 1-byte signed integer from -2^7 (-128) to 2^7-1 (127).
+  * !TinyInt: 1-byte signed integer from -2^7^ (-128) to 2^7^-1 (127).
-  * !SmallInt: 2-byte signed integer from -2^15 (-32768) to 2^15-1 (32767).
+  * !SmallInt: 2-byte signed integer from -2^15^ (-32768) to 2^15^-1 (32767).
-  * Int: 4-byte signed integer from -2^31 to 2^31-1.
+  * Int: 4-byte signed integer from -2^31^ to 2^31^-1.
-  * !BigInt: 8-byte signed integer from -2^63 to 2^63-1.
+  * !BigInt: 8-byte signed integer from -2^63^ to 2^63^-1.
   * Double: 8-byte double-precision float.
   * Boolean: 1-bit true or false flag.
   * String: Arbitrary-length unicode string (will be encoded in utf-8 in serialization/deserialization)
  
  All types can take a special value called NULL, as per SQL standard.
  
- Float is not supported because it's not supported by Thrift, and Hive uses Thrift a lot
for internal data serialization/deserialization.
+ Note: Float is not supported because it's not supported by Thrift, and Hive uses Thrift
a lot for internal data serialization/deserialization.
  
- Examples of creating a table with columns of various types:
+ Examples of creating a table with columns of various primitive types:
  
  {{{
  CREATE TABLE test_table (
@@ -28, +30 @@

  );
  }}}
  
+ === Complex Types ===
+ Complex Types are built up from primitive types and other complex types using:
+  * Struct: the elements within the type can be accessed using the . notation e.g. for a
column c of type struct {a int; b int} the a field is accessed by the expression a.c
+  * Map (key-value tuples): The elements are accessed using ['element name'] notation e.g.
in a map M comprising of a mapping from 'group' -> gid the gid value can be accessed using
M['group']
+  * Array (indexable lists): The elements are accessed using the [n] notation where n is
an index into the array e.g. for an array A having the elements ['a', 'b', 'c'], A[1] retruns
'b'. The index starts from 0.
+ 
  == Implicit and Explicit Type Conversions ==
  In most cases, users don't need to care about the types because Hive is able to do implicit
type conversions.
- However there are some cases that user wants to convert the values by himself.
+ However there are some cases that user wants to explicitly convert the type.
  
+ {{{
+ CAST(1.5 AS INT) = 2
+ CAST(-1.5 AS INT) = -2
+ CAST(FALSE AS INT) = 0
+ CAST(TRUE AS INT) = 1
+ CAST(0 AS BOOLEAN) = FALSE
+ CAST(1 AS BOOLEAN) = TRUE
+ CAST(0.1 AS BOOLEAN) = TRUE
+ CAST(FALSE AS STRING) = 'false'
+ CAST(TRUE AS STRING) = 'true'
+ }}}
  
- In particular, these are several special cases.
- 

Mime
View raw message