如何检查配置单元中是否存在任何特定分区:我的配置单元表中有如下分区:国家=印度/州=mh国家=美国/州=纽约我想检查country=“something”和state=“something”是否存在于配置单元中或使用shell脚本。请帮助
ubof19bj1#
描述mytable分区(…)显示像mytable分区一样扩展的表(…)使用从shell执行 hive -e '...' ####演示
hive -e '...'
create table mytable (i int) partitioned by (year int,month tinyint,day tinyint) ; insert into mytable partition(year,month,day) values (1,2017,3,29) ; hive> desc mytable partition (year=2017,month=3,day=29); OK i int year int month tinyint day tinyint # Partition Information # col_name data_type comment year int month tinyint day tinyint hive> desc mytable partition (year=2017,month=4,day=1); FAILED: SemanticException [Error 10006]: Partition not found {year=2017, month=4, day=1} hive> show table extended like mytable partition (year=2017,month=3,day=29); OK tableName:mytable owner:cloudera location:hdfs://quickstart.cloudera:8020/user/hive/warehouse/mytable/year=2017/month=3/day=29 inputformat:org.apache.hadoop.mapred.TextInputFormat outputformat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat columns:struct columns { i32 i} partitioned:true partitionColumns:struct partition_columns { i32 year, byte month, byte day} totalNumberFiles:1 totalFileSize:2 maxFileSize:2 minFileSize:2 lastAccessTime:1490770378864 lastUpdateTime:1490770379748 hive> show table extended like mytable partition (year=2017,month=4,day=1); FAILED: SemanticException [Error 10006]: Partition not found {year=2017, month=4, day=1}
yb3bgrhw2#
res=`hive -e "use {db}; show partitions {table} partition(country='india',state='MH')"` if [ ! -z "$res" ]; then do sth if the partition exists fi
您可以为其他分区进行复制。
lc8prwob3#
hive -e "use <db>; show partitions <table>;" egrep --color '<countryName>|<stateName>'
前任: hive -e "use db; show partitions table;" egrep --color 'India|MH' 这将为您提供所有匹配分区,其结果与india或mh或两者都匹配
hive -e "use db; show partitions table;" egrep --color 'India|MH'
3条答案
按热度按时间ubof19bj1#
描述mytable分区(…)
显示像mytable分区一样扩展的表(…)
使用从shell执行
hive -e '...'
####演示yb3bgrhw2#
您可以为其他分区进行复制。
lc8prwob3#
前任:
hive -e "use db; show partitions table;" egrep --color 'India|MH'
这将为您提供所有匹配分区,其结果与india或mh或两者都匹配