查看表分区相关信息(我常用来查看分区对应的hdfs路径)
desc formatted table_name partition(dt=20170227)
查看表相关信息
desc formatted table_name;
查看表结构信息
desc table_name;
查看建表语句
show create table mds_tblog_expo_dtl
查看分区信息
show partitions table_name;
hive模糊搜索表
show tables like '*name*';
判断分区是否有数据
-bash-3.2$ hadoop fs -help
...
-test -[defsz] <path>: Answer various questions about <path>, with result via exit status.
-d return 0 if <path> is a directory.
-e return 0 if <path> exists.
-f return 0 if <path> is a file.
-s return 0 if file <path> is greater than zero bytes in size.
-z return 0 if file <path> is zero bytes in size.
else, return 1.
yesterday=$(date -d '-1 day' '+%Y-%m-%d')
hadoop fs -test -e /user/hive/warehouse/yhd_gmv_month/ds=$yesterday
if [ $? -eq 0 ] ;then
echo 'exist'
else
echo 'Error! Directory is not exist'
fi