hive collection data type
来源:互联网 发布:唛头打印软件 编辑:程序博客网 时间:2024/04/29 23:34
Hive supports columns that are structs, maps, and arrays
create table
hive >create table employees3(name STRING,
salary FLOAT, subordinates ARRAY<STRING>,
deductions MAP<STRING,FLOAT>,
address STRUCT<street:STRING,city:STRING,state:STRING,zip:INT>)
ROW FORMAT DELIMITED FIELDS TERMINATED BY'\001' COLLECTION ITEMS TERMINATED BY '\002' MAP KEYS TERMINATED BY '\003'lines terminated by '\n' stored as textfile;
load data
hive >loaddata LOCAL INPATH '/root/employees.txt.1' OVERWRITE INTO TABLE employee3;
注意: \001, \002,\003 这些分隔符是不能通过vim 输入的,我是写java 代码生成的。
public static void main(String[] args){
char[] a={1};
char[] b={2};
char[] c={3};
try {
File file =new File("/root/employees.txt.1");
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
bw.write("John Doe");
bw.write(a);
bw.write("100000.0");
bw.write(a);
bw.write("Mary Smith");
bw.write(b);
bw.write("Todd Jones");
bw.write(a);
bw.write("Federal Taxes");
bw.write(c);
bw.write(".2");
bw.write(b);
bw.write("BState Taxes");
bw.write(c);
bw.write(".5");
bw.write(b);
bw.write("Insurance");
bw.write(c);
bw.write(".1");
bw.write(a);
bw.write("1 Michigan Ave.");
bw.write(b);
bw.write("BChicago");
bw.write(b);
bw.write("IL");
bw.write(b);
bw.write("60600");
bw.close();
System.out.println("Done");
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
Hive’s default record and field delimiters
Delimiter Description
\n For text files, each line is a record, so the line feed character separates records.
^A (“control” A) Separates all fields (columns). Written using the octal code \001 when explicitly
specified in CREATE TABLE statements.
^B Separate the elements in an ARRAY or STRUCT, or the key-value pairs in a MAP.
Written using the octal code \002 when explicitly specified in CREATE TABLE
statements.
^C Separate the key from the corresponding value in MAP key-value pairs. Written using
the octal code \003 when explicitly specified in CREATE TABLE statements.
More you can reference chapter3 of Programming Hive
- hive collection data type
- Data Type
- Data Type
- DATA TYPE
- Data Type
- setParameterList(String ,collection,Type);
- Strong-Type Collection
- data-type,data-value
- Big Data Science Collection
- Digital Data Collection course
- 【Data Structures】 1. Collection
- Android performance data collection
- Delphi Data Type to C# Data Type
- enum data type
- windows data type
- PLI Data Type
- DB2 Data Type
- data type : 数据类型
- Struts2中的OGNL表达式
- FFmpeg浅尝辄止(四)——音频的解码和编码
- 高性能的MySQL(5)索引策略一聚簇索引
- 非官方 iOS 8 概念展示:让首页更简单、好用的缩放 Widgets
- vs2010 format source code
- hive collection data type
- android缓存框架ASimpleCache
- Linux那些事儿 之 我是PCI(0)引子
- MySQL参考手册第7章:数据库的备份与恢复
- 输入123,输出壹佰贰拾叁
- W5500 ARM mbed 库发布
- iPhone . iPad . Mac 竟被遥控锁机, 给钱才能赎回装置 _0
- Oracle - 数据库的实例、表空间、用户、表之间关系
- IAP 方式