Hive 从pig中的配置单元表加载最新分区

Hive 从pig中的配置单元表加载最新分区,hive,Hive,我想知道如何在pig脚本中从配置单元表加载最新分区。显然,我可以加载整个数据,然后使用FILTER命令过滤相应的分区 但是,如果我们不知道配置单元表的最新日期分区是什么,我们如何获取最新日期本身并加载相应日期的分区?据我所知,我们不能直接这样做。我用shell脚本指出了一些方法。希望您的分区列是datehour格式或numarical增量顺序 hive -e 'select max(datehour) from tweets1' > datehour.txt; # i am sto

我想知道如何在pig脚本中从配置单元表加载最新分区。显然,我可以加载整个数据,然后使用FILTER命令过滤相应的分区


但是,如果我们不知道配置单元表的最新日期分区是什么,我们如何获取最新日期本身并加载相应日期的分区?

据我所知,我们不能直接这样做。我用shell脚本指出了一些方法。希望您的分区列是datehour格式或numarical增量顺序

hive -e 'select max(datehour) from tweets1' > datehour.txt;

   # i am storing of above query output to one temp file datehour.txt

datehour=$(awk '{print $0}' /home/winit/Desktop/needtocopy1/hivequeries/datehour.txt)

   # reading that file with above command.

 hive -e 'describe formatted tweets1  partition (datehour='$datehour')' > partitionloc.txt;

   # with describe command i am storing output to onemore temp file.

 partionLocation=$(awk '/Location:/ { print $2 }' partitionloc.txt)

  # i am reading the temp file with pattern 'Location',its partition location

  # pass the location to pig script as parameter to load data from..

 pig  -f  pigfile.pig --param location=$partionLocation
如果不起作用,请告诉我