External table does not return the data in its folder

前端 未结 2 1825
别跟我提以往
别跟我提以往 2021-01-21 03:02

I have created an external table in Hive with at this location :

CREATE EXTERNAL TABLE tb 
(
...
) 
PARTITIONED BY (datehour INT)
ROW FORMAT SERDE \'com.cloudera         


        
2条回答
  •  猫巷女王i
    2021-01-21 03:18

    You have created your table as partitioned table base on column datehour, but you are putting your data in /user/cloudera/data. Hive will look for data in /user/cloudera/data/datehour=(some int value). Since it is an external table hive will not update the metastore. You need to run some alter statement to update that

    So here are the steps for external tables with partition:

    1.) In you external location /user/cloudera/data, create a directory datehour=0909201401

                                    OR
    

    Load data using: LOAD DATA [LOCAL] INPATH '/path/to/data/file' INTO TABLE partition(datehour=0909201401)

    2.) After creating your table run a alter statement: ALTER TABLE ADD PARTITION (datehour=0909201401)

    Hope it helps...!!!

提交回复
热议问题