[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
[Hive - Tutorial] Type System 数据类型的更多相关文章
- Hive Tutorial(上)(Hive 入门指导)
用户指导 Hive 指导 Hive指导 概念 Hive是什么 Hive不是什么 获得和开始 数据单元 类型系统 内置操作符和方法 语言性能 用法和例子(在<下>里面) 概念 Hive是什么 ...
- Hive Tutorial 阅读记录
Hive Tutorial 目录 Hive Tutorial 1.Concepts 1.1.What Is Hive 1.2.What Hive Is NOT 1.3.Getting Started ...
- [Hive - Tutorial] Built In Operators and Functions 内置操作符与内置函数
Built-in Operators Relational Operators The following operators compare the passed operands and gene ...
- 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 ...
- [Hive - Tutorial] Creating, Showing, Altering, and Dropping Tables
Creating, Showing, Altering, and Dropping Tables See Hive Data Definition Language for detailed info ...
- 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 ...
- 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 ...
- 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 ' ...
- 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, ...
随机推荐
- 设计模式之工厂方法模式VS简单工厂方法模式
名词解释: 简单工厂:这个实在是没什么解释的,就是一个工厂类,然后有一个方法,根据传递的参数可以通过switch(你也可以是if,或者是使用高端的反射 )来进行对象的创建. 工厂方法:定义一个用于创建 ...
- 值得珍藏的.NET源码,不保存就没机会了
很早以前,我们通过http://referencesource.microsoft.com/netframework.aspx可以下载到.NET的各版本公开源码,但如今,微软对sscli项目进行了改版 ...
- Lunix中文乱码解决方案
sudo vi /var/lib/locales/supported.d/local#添加下面的中文字符集zh_CN.GBK GBKzh_CN.GB2312 GB2312zh_CN.GB18030 G ...
- C++中求两个正整数的最大公约数和最小公倍数
最大公约数直接用辗转相除法,最小公倍数就是两个数的乘积除以最大公约数 #include<iostream> using namespace std; int gys(int x,int y ...
- 用net匹配并替换iOS标准的emoji表情符号
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespaceCommo ...
- UVa 10288 (期望) Coupons
题意: 每张彩票上印有一张图案,要集齐n个不同的图案才能获奖.输入n,求要获奖购买彩票张数的期望(假设获得每个图案的概率相同). 分析: 假设现在已经有k种图案,令s = k/n,得到一个新图案需要t ...
- bzoj1834: [ZJOI2010]network 网络扩容
努力看了很久样例一直过不了...然后各种输出中间过程啊巴拉巴拉弄了1h,没办法了...然后突然想到啊原来的边可以用啊为什么不用...于是A了...感人肺腑 #include<cstdio> ...
- 从MySpace基于.NET平台的六次重构经历感受分布式
它们拥有的用户和fans之多,大家都很清楚. Myspace是一个基于.NET平台的,而Facebook更多是基于LAMP的.我们来看看MySpace配合.NET+Windows Server 200 ...
- WebView线性进度条
参考:http://www.cnblogs.com/hubli/p/4835549.html APP会跳转网页时候,请参考:http://blog.csdn.net/raphael55/article ...
- 【Java学习笔记】Hello world
package aaa; public class aaa { public static void main(String args[]){ System.out.println("hel ...