基于hdfs文件创建hive表

时间:2021-03-03 12:21:19   收藏:0   阅读:0

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"}
     ]
}‘);

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!