温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

【总结】各种数据格式的Hive建表语句

发布时间:2020-05-16 11:14:15 来源:网络 阅读:11391 作者:巧克力黒 栏目:大数据

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'

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI