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

基于hdfs文件创建hive表

时间:2021-03-03 12:21:19      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:code   prope   ros   mail   example   data   string   row   create   

create table customer
row format SERDE ‘org.apache.hadoop.hive.serde2.avro.AvroSerDe‘
stored as inputformat
‘org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat‘
outputformat
‘org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat‘
location ‘/datalake/raw/customer‘
tblproperties (
    ‘avro.schema.literal‘=‘{
    "namespace": "example.avro",
    "type": "record",
    "name": "Customer",
    "fields": [
        {"name":"id", "type":"int"},
        {"name":"first_name", "type":"string"},
        {"name":"last_name", "type":"string"},
        {"name":"dob", "type":"long"}
     ]
}‘);

create table address
row format SERDE ‘org.apache.hadoop.hive.serde2.avro.AvroSerDe‘
stored as inputformat
‘org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat‘
outputformat
‘org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat‘
location ‘/datalake/raw/address‘
tblproperties (
    ‘avro.schema.literal‘=‘{
    "namespace": "example.avro",
    "type": "record",
    "name": "Address",
    "fields": [
        {"name":"id", "type":"int"},
        {"name":"street1", "type":"string"},
        {"name":"street2", "type":"string"},
        {"name":"city", "type":"string"},
        {"name":"state", "type":"string"},
        {"name":"country", "type":"string"},
        {"name":"zip_pin_postal_code", "type":"string"}
     ]
}‘);


create table contact
row format SERDE ‘org.apache.hadoop.hive.serde2.avro.AvroSerDe‘
stored as inputformat
‘org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat‘
outputformat
‘org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat‘
location ‘/datalake/raw/contacts/load1‘
tblproperties (
    ‘avro.schema.literal‘=‘{
    "namespace": "example.avro",
    "type": "record",
    "name": "Contact",
    "fields": [
        {"name":"id", "type":"string"},
        {"name":"cell", "type":"string"},
        {"name":"phone", "type":"string"},
        {"name":"email", "type":"string"}
     ]
}‘);

基于hdfs文件创建hive表

标签:code   prope   ros   mail   example   data   string   row   create   

原文地址:https://www.cnblogs.com/rigid/p/14472230.html

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