数据类型
Type System

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

Hive支持原生和复杂数据类型。

Primitive Types

原生数据类型

  • Types are associated with the columns in the tables. The following Primitive types are 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 are organized in the following hierarchy (where the parent is a super type of all the children instances):

数据类型层次关系:

  • Type

    • Primitive Type

      • Number

        • DOUBLE

          • FLOAT

            • BIGINT

              • INT

                • SMALLINT

                  • TINYINT

          • STRING

      • BOOLEAN

This type hierarchy defines how the types are 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 is 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.

在SQL中可进行类型转换,但是只能是子数据类型转换成祖先数据类型。另外,字符串类型也可以转为Double类型

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

Complex Types

复杂数据类型

Complex Types can be 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 is accessed by the expression c.a
  • Maps (key-value tuples): The elements are 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 have to be in the same type. Elements can be accessed using the [n] notation where n is an index (zero-based) into the array. For example for an array A having the elements ['a', 'b', 'c'], A[1] retruns 'b'.

复杂数据类型支持:Structs,Maps,Arrays 三种。并且可以嵌套使用。

Using the primitive types and the constructs for creating complex types, types with arbitrary levels of nesting can be created. For example, a type User may 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 数据类型的更多相关文章

  1. Hive Tutorial(上)(Hive 入门指导)

    用户指导 Hive 指导 Hive指导 概念 Hive是什么 Hive不是什么 获得和开始 数据单元 类型系统 内置操作符和方法 语言性能 用法和例子(在<下>里面) 概念 Hive是什么 ...

  2. Hive Tutorial 阅读记录

    Hive Tutorial 目录 Hive Tutorial 1.Concepts 1.1.What Is Hive 1.2.What Hive Is NOT 1.3.Getting Started ...

  3. [Hive - Tutorial] Built In Operators and Functions 内置操作符与内置函数

    Built-in Operators Relational Operators The following operators compare the passed operands and gene ...

  4. JsonException: Max allowed object depth reached while trying to export from type System.Single

    在进行类转json字符串时,报错JsonException: Max allowed object depth reached while trying to export from type Sys ...

  5. [Hive - Tutorial] Creating, Showing, Altering, and Dropping Tables

    Creating, Showing, Altering, and Dropping Tables See Hive Data Definition Language for detailed info ...

  6. Beginning Scala study note(8) Scala Type System

    1. Unified Type System Scala has a unified type system, enclosed by the type Any at the top of the h ...

  7. Could not load type 'System.Reflection.AssemblySignatureKeyAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c

    错误: Could not load type 'System.Reflection.AssemblySignatureKeyAttribute' from assembly 'mscorlib, V ...

  8. foreach statement cannot operate on variables of type 'System.Web.UI.WebControls.Table' because 'System.Web.UI.WebControls.Table' does not contain a public definition for 'GetEnumerator'

    错误:foreach statement cannot operate on variables of type 'System.Web.UI.WebControls.Table' because ' ...

  9. Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

    Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, ...

随机推荐

  1. android actionbar标题栏

    在android的actionBar中,actionBar的视图是固定的,左边是程序的图标和title,右边是添加的menuItem,如果想要定制actionbar中的view就要自定义视图. 首先要 ...

  2. EF 实体关系

    基于共享主键的一对一: this.HasRequired(t => t.TRDConInfo) .WithOptional(t => t.TRDFoundationProjCheck); ...

  3. JVM学习笔记(一)------基本结构

    从Java平台的逻辑结构上来看,我们可以从下图来了解JVM: 从上图能清晰看到Java平台包含的各个逻辑模块,也能了解到JDK与JRE的区别 对于JVM自身的物理结构,我们可以从下图鸟瞰一下: 对于J ...

  4. Android权限安全(11)内置计费相关安全要点

    内置计费相关安全要点 1.计费Server接口保密且Transiction 加密 (SSL) 2.仅允许配套的安全本地组件(通常是第三方付费sdk如支付宝)与计费Server通信,且安全本地组件负责与 ...

  5. 面试题_93_to_102_编程和代码相关的面试题

    93)怎么检查一个字符串只包含数字?(解决方案) 94)Java 中如何利用泛型写一个 LRU 缓存?(答案<) 95)写一段 Java 程序将 byte 转换为 long?(答案) 95)在不 ...

  6. 关于<img>标签与文字垂直居中

    要让左边的图片与后面的文字居中,如下效果 HTML代码: <img class="iconCls" alt="最新客户端" src="${bas ...

  7. 命名空间“System.Web”中不存在类型或命名空间名称“Script”(是缺少程序集引用吗?)

    网上有些资料说,在项目上鼠标右键,添加引用→.Net→System.Web.Entensions就可以了. 实际上很多时候在项目中的添加引用窗口上,根本找不到System.Web.Entensions ...

  8. bzoj1355: [Baltic2009]Radio Transmission

    将原串看成是循环节的后缀加上若干个循环节,那么考虑每种情况都会发现n-next[n]就是最小循环节.(一开始总输出n...然后发现build_next连调用都没有,%%% #include<cs ...

  9. sql server压缩数据库和日志文件

    DBCC SHRINKDATABASE 功能:压缩数据库 用法:DBCC SHRINKDATABASE tb_115sou_com 注意:只有产生许多未使用空间的操作(如截断表或删除表操作)后,执行收 ...

  10. 苹果官方 Crash文件分析方法 (iOS系统Crash文件分析方法)

    对于提交的苹果官方的app,在审核的时候会给我们一些crash文件,对于这些有用的文件,里面是关于我们的bug的一些信息,那么该如何去调试呢 第一步:在任意目录创建一个目录,用来调试crash,我这里 ...