Support Questions

Find answers, ask questions, and share your expertise

How to move files from HDFS to HIVE?

avatar
Rising Star

Hi..

I have set of .csv files in HDFS folder with different columns, i want to move this files to HIVE dynamically. How to move this set of files to HIVE ? please help me and thanks in advance

1 ACCEPTED SOLUTION

avatar
@Manikandan Durairaj

Here is the sample code:

CREATE EXTERNAL TABLE IF NOT EXISTS Cars(
        Name STRING, 
        Miles_per_Gallon INT,
        Cylinders INT,
        Displacement INT,
        Horsepower INT, 
        Weight_in_lbs INT,
        Acceleration DECIMAL,
        Year DATE,
        Origin CHAR(1))
    COMMENT 'Data about cars from a public database'
    ROW FORMAT DELIMITED
    FIELDS TERMINATED BY ','
    STORED AS TEXTFILE
    location '/user/<username>/visdata'; 

Link might help you more

https://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.3.0/bk_dataintegration/content/moving_data_from...

View solution in original post

3 REPLIES 3

avatar
@Manikandan Durairaj

Here is the sample code:

CREATE EXTERNAL TABLE IF NOT EXISTS Cars(
        Name STRING, 
        Miles_per_Gallon INT,
        Cylinders INT,
        Displacement INT,
        Horsepower INT, 
        Weight_in_lbs INT,
        Acceleration DECIMAL,
        Year DATE,
        Origin CHAR(1))
    COMMENT 'Data about cars from a public database'
    ROW FORMAT DELIMITED
    FIELDS TERMINATED BY ','
    STORED AS TEXTFILE
    location '/user/<username>/visdata'; 

Link might help you more

https://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.3.0/bk_dataintegration/content/moving_data_from...

avatar
Rising Star

thanks for ur reply sri but i have following doubt please give any solution

how to create the hive table dynamically based on the csv files.

for example, if csv1 file consists of 3 columns and csv2 file consists of 4 columns how to create hive table dynamically for both

avatar
Rising Star

how to create the hive table dynamically based on the csv files.

for example, if csv1 file consists of 3 columns and csv2 file consists of 4 columns how to create hive table dynamically for both