R 故障保护恢复分区

R 故障保护恢复分区,r,apache-spark,apache-spark-sql,sparkr,R,Apache Spark,Apache Spark Sql,Sparkr,我想在可能有分区也可能没有分区的表上运行recoverPartitions 现在我看到了两种选择,这两种选择都让人感觉很不舒服: (1) 执行之前,请检查create table语句: table_name = 'my_schema.my_table' x = sql(sprintf('show create table %s', table_name)) if (grepl('PARTITIONED BY', collect(x), fixed = TRUE)) { recoverPart

我想在可能有分区也可能没有分区的表上运行
recoverPartitions

现在我看到了两种选择,这两种选择都让人感觉很不舒服:

(1) 执行之前,请检查
create table
语句:

table_name = 'my_schema.my_table'
x = sql(sprintf('show create table %s', table_name))
if (grepl('PARTITIONED BY', collect(x), fixed = TRUE)) {
  recoverPartitions(table_name)
}
(2)
tryCatch

tryCatch(recoverPartitions(table_name),
         error = function(e) {
  if (grepl('ALTER TABLE RECOVER PARTITIONS', e$message, fixed = TRUE)) 
    # expected error in case of non-partitioned table
    return(NULL)
  # else an unexpected error
  else stop(e$message, .call = FALSE)
})
这些真的是灵活恢复分区的“正确”/“规范”方法吗?我在中没有看到任何其他内容,在
SparkR
名称空间
格式中的
[pP]artition
搜索中也没有看到任何提示性内容

如果是这样的话,其中一个是否优于另一个(如效率)