Search code examples
csvhadoophivebeeline

load data from csv file to table hive


Im new using hive,

table tb1 is created as below:

create external table tb1 
(id string,
name string, 
product string, 
depart string)
PARTITIONED BY (dt DATE);

I want to insert data in external tables using the command below:

LOAD DATA INPATH '/peoject010212/hive/data_tb1.csv' into table tb1 partition (dt='2022-03-12')

The data is inserted but in wrong format in the table. all the file is loaded in the first column. the table tb1 columns are: id, name, product, depart, dt the content of the file is:

12,xxx,yy,zz
13,xxy,yz,zt

Who can help me please?

Danke,


Solution

  • Try to create a table like below:

    CREATE EXTERNAL TABLE tb1 (
    id int,
    name string, 
    product string, 
    depart string) 
    PARTITIONED BY (dt DATE)
    ROW FORMAT DELIMITED
    FIELDS TERMINATED BY ','
    STORED AS TEXTFILE;