r-为什么Rscript会在RStudio没有终止时自动终止?
发布时间:2022-06-12 13:33:59 367
相关标签: # 数据库# 数据# 脚本
我正在执行一个 ETL,它将数据从 R 脚本推送到雪花数据库中。该脚本在 RStudio 中使用预期的消息运行,但在 Rscript.exe 中运行时,它会静默终止,不会从 tryCatch() 函数打印。我在 4.1.2。
下面片段中的 dup_final 数据集的数据结构:
代码段:
# limit to one record per key
dup_final <- subset(dup_final,duplicated(dup_final$key))
print("Number of duplicates to be written to Snowflake:")
print(nrow(dup_final))
# drop key field
dup_final <- dup_final[,-8]
# save off data in case failure to write
saveRDS(dup_final,"C:/Users/might_frosty_dragonsbane.rds")
# upload data to Snowflake
tryCatch(
expr = DBI::dbWriteTable(
conn = conn_snow_audit,
"DUPLICATE_PHOTO",
dup_final,
append = TRUE
),
error = function(e) {
print(
"ERROR: Write of DUPLICATE_PHOTO to Snowflake failed upon execution."
)
sink()
q()
},
finally = print(
"DUPLICATE_PHOTO successfully written to Snowflake."
)
)
message("The program executed successfully,and this window will close in 10 seconds...")
Sys.sleep(10)
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报