[Hive-Tutorial] Type System 数据类型

数据类型
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

时间: 2024-11-05 18:43:17

[Hive-Tutorial] Type System 数据类型的相关文章

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 System.Single. ok,实际上是类的属性中有json不能识别的数据类型,我这里就脑残的float.去除掉之后就ok了. (备注:用的是LitJson) 那一般什么类型是允许的呢? 我在JsonData类中找到了答案. public JsonData(bool boolean); public

CORE EF The expected type was 'System.String' but the actual value was of type 'System.Guid'.

[小提示]使用.NET Core EF 开发时,当你的数据库实体中添加了"Id"的字段时,会默认做为主键. 在设置数据库字段类型时如果设置了varchar或者char字段的长度为36时(36是微软GUID的长度),并且数据存储的数据正好是Guid字符串时,在使用EF查询数据库时EF会自动把数据类型转为Guid类型,如果你的数据库实体类中对应的字段正好是string类型时会抛出以下异常: An exception occurred while reading a database val

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 hierarchy and the type Nothing at the bottom of the hierarchy. All Scala types inherit from Any. # Using Any, Book extends AnyRef, and x is an Int that

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, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 问题描述: 再windows server 2008 r2 环境下搭建.net网站 ,运行是IIS7.0提示以上问题 解决方案: 这里需要注册一下ASP.NET 4.

Could not load type 'System.Web.Mvc.ViewPage<dynamic>' in asp.net mvc2 after publishing the website

在WebConfig里 找到 <pages></pages> <pages pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System

ADT(Abstract Data Type)抽象数据类型

ADT(Abstract Data Type)抽象数据类型 为了便于理解,以复数为例: (1)定义: ADT Complex{ 数据对象:D={e1,e2|e1,e2为实数} 数据关系:S={<e1,e2>|e1是实部,e2是虚部} 基本操作: Creat(&C , x, y) GetReal(C) GetImage(C) Add(c1,c2) Sub(C1,C2) } ADT Complex; (2)表示: typedef struct{ float Realpart; float

解决:Could not load type &#39;System.ServiceModel.Activation.HttpModule&#39; from assemb

解决:Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceMode 今天我发布项目,获取运行出错如下: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceMode 解决:Could not load type 'System.Se

Go’s Type System Is An Embarrassment

Go is one of the best tools out there today for heavy lifting and backend code. It's my go to language when it's time to bring out the big guns and I enjoy working with it immensely. That being said, its type system is an embarrassment. It's meant to

使用Ef查询出现的问题The cast to value type &#39;System.Boolean&#39; failed because the materialized value is null.的解决方法

把值类型的系统.布尔的失败是因为物化值是null.结果类型的泛型参数或查询必须使用可空类型. 解决方法: 请确保你查询中的字段值不为空或者做为空判断 使用Ef查询出现的问题The cast to value type 'System.Boolean' failed because the materialized value is null.的解决方法