Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 HiveQL 脚本,它可以基于 hive 表执行一些操作。但在做这些操作之前,我会检查需要的分区是否存在,如果不存在,我会终止脚本。那么我该如何实现呢?
使用外壳:
table_name="schema.table" partition_spec="key=value" partition_exists=$(hive -e "show partitions $table_name" | grep "$partition_spec"); #check partition_exists if [ "$partition_exists" = "" ]; then echo not exists; else echo exists; fi