码迷,mamicode.com
首页 > 其他好文 > 详细

各种数据格式的Hive建表语句

时间:2018-05-22 22:20:12      阅读:581      评论:0      收藏:0      [点我收藏+]

标签:大数据   Hive   

Xml格式

CREATE EXTERNAL TABLE Gateway_pmsarisoap(

BookingSoapLogID STRING,?

GuidNo STRING,?

SoapType STRING,?

SoapContent STRING,?

InsertDate STRING,?

SourceOpsType STRING)

PARTITIONED BY (?

? `dt` string)

ROW FORMAT SERDE ‘com.ibm.spss.hive.serde2.xml.XmlSerDe‘

WITH SERDEPROPERTIES (

"column.xpath.BookingSoapLogID"="/HWSoapBase/BookingSoapLogID/text()",

"column.xpath.GuidNo"="/HWSoapBase/GuidNo/text()",

"column.xpath.SoapType"="/HWSoapBase/SoapType/text()",

"column.xpath.SoapContent"="/HWSoapBase/SoapContent/*",

"column.xpath.InsertDate"="/HWSoapBase/InsertDate/text()",

"column.xpath.SourceOpsType"="/HWSoapBase/SourceOpsType/text()"

)

STORED AS

INPUTFORMAT ‘com.ibm.spss.hive.serde2.xml.XmlInputFormat‘

OUTPUTFORMAT ‘org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat‘

LOCATION ‘hdfs://ns1/wh/source/hw/Gateway/PmsARISoap‘

TBLPROPERTIES (

"xmlinput.start"="<HWSoapBase",

"xmlinput.end"="</HWSoapBase>"

);

Json格式

CREATE EXTERNAL TABLE QuhuhuGateway_pmsinvcountnotify(

CountType string,

Count string,

HotelCode string,

Start string,

`End` string)?

PARTITIONED BY (dt string)?

ROW FORMAT SERDE ‘com.cloudera.hive.serde.JSONSerDe‘?

STORED AS INPUTFORMAT ‘com.hadoop.mapred.DeprecatedLzoTextInputFormat‘?

OUTPUTFORMAT ‘org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat‘?

LOCATION ‘hdfs://ns1/wh/source/hw/QuhuhuGateway/PmsInvCountNotify‘;

ORC格式

create external table BWAdmin_Log(

? `LogID` BIGINT,?

? `AccountID` BIGINT,??

? `VHotelID` BIGINT,?

? `LogType` String,?

? `LogComment` String,

? `OperateTime` INT

)

row format delimited

fields terminated by ‘\t‘

STORED AS ORC

location?

‘hdfs://ns1/wh/source/bw/hotel/admin_log‘

AVRO格式

CREATE EXTERNAL TABLE `hotel_list`

PARTITIONED BY ( `dt` string)

ROW FORMAT SERDE ‘org.apache.hadoop.hive.serde2.avro.AvroSerDe‘

WITH SERDEPROPERTIES( ‘avro.schema.url‘=‘hdfs://ns1/wh/config/schema/web/online/hotel_list.avsc‘)

STORED AS INPUTFORMAT ‘org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat‘

OUTPUTFORMAT ‘org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat‘

LOCATION ‘hdfs://ns1/wh/format/online_search‘;

LZO格式

CREATE EXTERNAL TABLE online_test(

sid int,

pvid int,

ts bigint)

PARTITIONED BY ( dt string)

ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘\t‘

LINES TERMINATED BY ‘\n‘

STORED AS INPUTFORMAT‘com.hadoop.mapred.DeprecatedLzoTextInputFormat‘

OUTPUTFORMAT ‘org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat‘

LOCATION ‘hdfs://ns1/test/online‘;

TEXT格式

CREATE EXTERNAL TABLE `order_currenthis`(

`orderid` string,

`room` int)

PARTITIONED BY ( `dt` string)

ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘\t‘ LINES TERMINATED BY ‘\n‘

STORED AS INPUTFORMAT ‘org.apache.hadoop.mapred.TextInputFormat‘

OUTPUTFORMAT ‘org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat‘

LOCATION ‘hdfs://ns1/wh/format/otb/order_currenthis‘

各种数据格式的Hive建表语句

标签:大数据   Hive   

原文地址:http://blog.51cto.com/10120275/2119243

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!