[Hive-tutorial] Type System data type

Source: Internet
Author: User

Data type
Type System

Hive supports primitive and complex data types, as described below. See Hive Data Types for additional information.

Hive supports both native and complex data types.

Primitive Types

Native data type

    • Types is associated with the columns in the tables. The following Primitive types is supported:
    • Integers
      • TINYINT-1 byte integer
      • SMALLINT-2 byte integer
      • INT-4 byte integer
      • BIGINT-8 byte integer
    • Boolean type
      • Boolean-true/false
    • Floating point numbers
      • Float-single Precision
      • Double-double Precision
    • String type
      • String-sequence of characters in a specified character set

The Types is organized in the following hierarchy (where the parent was a super type of all the children instances):

Data type hierarchy Relationship:

  • Type
    • Primitive Type

      • Number

        • DOUBLE

          • FLOAT

            • bigint< /p>

              • INT

                • SMALLINT

                  • TINYINT

          • STRING

      • BOOLEAN

This type hierarchy defines how the types is implicitly converted in the query language. Implicit conversion is allowed for types from child to an ancestor. So when a query expression expects type1 and the data are of type2, type2 is implicitly converted to Type1 if Type1 is An ancestor of type2 in the type hierarchy. Note that the type hierarchy allows the implicit conversion of STRING to DOUBLE.

Type conversions can be done in SQL, but only the child data type is converted to the ancestor data type. In addition, string types can also be converted to double types

Explicit type conversion can be do using the cast operator as shown in the #Built of Functions section below.

Complex Types

Complex data types

Complex Types can is built up from primitive Types and other composite Types using:

    • Structs:the elements within the type can be accessed using the DOT (.) notation. For example, for a column C of type STRUCT {a INT; b int} The A field was accessed by the expression C.A
    • Maps (Key-value tuples): The elements is accessed using [' element name '] notation. For example in a map M comprising of a mapping from ' group ', gid the GID value can be accessed using m[' group ']
    • Arrays (indexable lists): The elements in the array has the to is in the same type. Elements can be accessed using the "n" notation where n is a index (zero-based) into the array. For example for an array A has the elements [' A ', ' B ', ' C '], a[1] retruns ' B '.

Complex data type support: Structs,maps,arrays three kinds. And can be used in a nested set.

Using the primitive types and the constructs for creating complex types, types with arbitrary levels of nesting can be CRE Ated. For example, a type User could comprise of the following fields:

    • Gender-which is a STRING.
    • Active-which is a BOOLEAN.

Https://cwiki.apache.org/confluence/display/Hive/Tutorial

[Hive-tutorial] Type System data type

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.