hive 逻辑分区概念
逻辑分区,可以使用ACTIVE作为最新分区,ACTIVE指向新一天数据:
describe formatted app.app_user_profile partition(dt='ACTIVE') ;
查询信息:
# Detailed Partition Information Partition Value: [ACTIVE] Database: app Table: app_user_profile CreateTime: Mon Mar 09 11:28:50 CST 2020 LastAccessTime: UNKNOWN Location: hdfs://ads/app.db/app_user_profile/dt=2002-03-08 Partition Parameters: numFiles 134 totalSize 40293757055 transient_lastDdlTime 1583724530 # Storage Information SerDe Library: org.apache.hadoop.hive.ql.io.orc.OrcSerde InputFormat: org.apache.hadoop.hive.ql.io.orc.OrcInputFormat OutputFormat: org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat Compressed: No Num Buckets: -1 Bucket Columns: [] Sort Columns: []
可以查看ACTIVE分区具体指向哪一个分区。
设置分区位置:
如果ACTIVE分区实现不存在,可以添加分区,添加分区时候可以不指定路径:
alter table app.app_order_daily add IF NOT EXISTS partition(dt='2050',pin='sadasdasd') ;