Loading Data from a .txt file to Table Stored as ORC in Hive

后端 未结 5 898
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 01:30

I have a data file which is in .txt format. I am using the file to load data into Hive tables. When I load the file in a table like

CREATE TABL         


        
5条回答
  •  抹茶落季
    2020-12-01 01:56

    LOAD DATA just copies the files to hive datafiles. Hive does not do any transformation while loading data into tables.

    So, in this case the input file /home/user/test_details.txt needs to be in ORC format if you are loading it into an ORC table.

    A possible workaround is to create a temporary table with STORED AS TEXT, then LOAD DATA into it, and then copy data from this table to the ORC table.

    Here is an example:

    CREATE TABLE test_details_txt( visit_id INT, store_id SMALLINT) STORED AS TEXTFILE;
    CREATE TABLE test_details_orc( visit_id INT, store_id SMALLINT) STORED AS ORC;
    
    -- Load into Text table
    LOAD DATA LOCAL INPATH '/home/user/test_details.txt' INTO TABLE test_details_txt;
    
    -- Copy to ORC table
    INSERT INTO TABLE test_details_orc SELECT * FROM test_details_txt;
    

提交回复
热议问题