Beehive of an external partitioned table

First I created an external bush table, broken down by code and date

CREATE EXTERNAL TABLE IF NOT EXISTS XYZ ( ID STRING, SAL BIGINT, NAME STRING, ) PARTITIONED BY (CODE INT,DATE STRING) ROW FORMAT SERDE 'parquet.hive.serde.ParquetHiveSerDe' STORED AS INPUTFORMAT "parquet.hive.DeprecatedParquetInputFormat" OUTPUTFORMAT "parquet.hive.DeprecatedParquetOutputFormat" LOCATION '/old_work/XYZ'; 

and then I do an overwrite insert in this table, taking data from another table

 INSERT OVERWRITE TABLE XYZ PARTITION (CODE,DATE) SELECT * FROM TEMP_XYZ; 

and after that I count the number of entries in the hive, select count (*) from XYZ; this shows that I have 1000 entries and then I rename or move the location / old _work / XYZ 'to' / new_work / XYZ '

and then I will remove the XYZ table again and again create an address location in a new directory means '/ new_work / XYZ'

 CREATE EXTERNAL TABLE IF NOT EXISTS XYZ ( ID STRING, SAL BIGINT, NAME STRING, ) PARTITIONED BY (CODE INT,DATE STRING) ROW FORMAT SERDE 'parquet.hive.serde.ParquetHiveSerDe' STORED AS INPUTFORMAT "parquet.hive.DeprecatedParquetInputFormat" OUTPUTFORMAT "parquet.hive.DeprecatedParquetOutputFormat" LOCATION '/new_work/XYZ'; 

But then when I execute select count (*) from the XYZ table in the hive, it shows 0 records, I think I missed something, please help me on this ????

+5
source share
1 answer

You do not need to drop the table and recreate it a second time:

Once you move or rename the external location of the hdfs table, do the following:

  msck repair table <table_name> 

In your case, the error was due to the fact that the hive metastability was not updated in a new way.

+5
source

Source: https://habr.com/ru/post/1206083/


All Articles