Hive External table-CSV File- Header row

后端 未结 6 614
甜味超标
甜味超标 2020-12-24 08:06

Below is the hive table i have created:

CREATE EXTERNAL TABLE Activity (
  column1 type, 
column2 type ) ROW FORMAT DELIMITED FIELDS TERMINATED
6条回答
  •  渐次进展
    2020-12-24 08:42

    Lets say you want to load csv file like below located at /home/test/que.csv

    1,TAP (PORTUGAL),AIRLINE
    2,ANSA INTERNATIONAL,AUTO RENTAL
    3,CARLTON HOTELS,HOTEL-MOTEL
    

    Now, we need to create a location in HDFS that holds this data.

    hadoop fs -put /home/test/que.csv /user/mcc

    Next step is to create a table. There are two types of them to choose from. Refer this for choosing one.

    Example for External Table.

    create external table industry_ 
    (
    MCC string ,
    MCC_Name string,
    MCC_Group string
    )       
    ROW FORMAT DELIMITED
    FIELDS TERMINATED BY ','
    STORED AS TEXTFILE
    LOCATION '/user/mcc/'
    tblproperties ("skip.header.line.count"="1");
    

提交回复
热议问题