r - 故障保护恢复分区
问题描述
我想recoverPartitions
在可能有也可能没有分区的表上运行。
现在我看到两个选项,这两个选项都感觉很hacky:
(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
我在文档中没有看到任何其他内容,并且在搜索 of[pP]artition
中没有看到任何暗示formals
性的Namespace
内容SparkR
。
如果是这样,一个优先于另一个(例如效率)吗?
解决方案
推荐阅读
- html - 为什么我的网络图片库中的项目在 ios 上消失了?
- codeception - 如果测试失败,如何在代码接收中回滚数据库?
- assembly - 关于汇编语言设置标志的逻辑问题
- php - 具有多个 slug 的 Laravel 路由在 React 中不起作用
- python - 整理熊猫实验的结果
- python - 将具有一个键和两个值的字典写入 csv 文件
- c# - 在 OData API 中修改表达式树
- python - 如何在不停止程序其余部分的情况下在 python 中进行延迟
- python - NCO/pynco:ncea 无法从 Python 中找到文件
- http - IIS:如何禁用 HTTP 方法 TRACE?