gpt4 book ai didi

shell - 如何检查HIVE中是否存在任何特定分区

转载 作者:可可西里 更新时间:2023-11-01 14:26:31 34 4
gpt4 key购买 nike

如何检查HIVE中是否存在任何特定分区:

我的 hive 表中有如下分区:

国家=印度/州=MH 国家=美国/州=纽约

我想检查 country = "something and state="something"是否存在于 HIVE 或使用 shell 脚本中。请帮忙

最佳答案

  1. desc mytable 分区 (...)
  2. 显示像 mytable 分区一样扩展的表 (...)

使用 hive -e '...' 从 shell 执行

演示

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}

关于shell - 如何检查HIVE中是否存在任何特定分区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43086158/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com