我已经用R编写了一个函数,该函数从数据库中提取数据并建立一个新表。
我的新表格上标有摘录的日期(build_date_0
)。
调试函数时,当我查看日期字符串时会收到以下警告:
Browse[2]> build_date_0
[1] "2019-05-01"
Warning message:
In get(object, envir = currentEnv, inherits = TRUE) :
restarting interrupted promise evaluation
问题:
这是我的代码:
build_account_db = function(conn = connection_object
,various_inputs = 24){
browser()
# create connection objects
tabs_1 = dplyr::tbl(conn,in_schema("DB_1","VIEW_W") # some table
# create date string
build_date_0 = lubridate::today() %>% as.character()
build_date = str_replace_all(build_date_0,"-+","_")
db_name_1 = paste0('DATABASE.tab_1_',build_date)
db_name_2 = paste0('DATABASE.tab_2_',build_date)
# build query
query_text_1 = tabs_1 %>% select(COL_1) # some query
query_text_1 = tabs_1 %>% select(COL_2)
# build new tables
create_db = DBI::dbSendQuery(conn_t,paste('CREATE TABLE',db_name_1,'AS (',query_text_1,') WITH DATA PRIMARY INDEX (ID_1)'))
create_db2 = DBI::dbSendQuery(conn_t,paste('CREATE TABLE',db_name_2,'AS (',query_text_2,') WITH DATA PRIMARY INDEX (ID_1)'))
}
当我检查变量时,我可能会或可能不会收到此警告(即使重新启动R,并在清除的环境下再次运行代码,警告也会有所不同)
Browse[2]> build_date
[1] "2019-02-28 11:00:00 AEDT"
Warning message:
In get(object, envir = currentEnv, inherits = TRUE) :
restarting interrupted promise evaluation
我尝试过的方法:I read this question,但这更多的是抑制错误。另外,谷歌。
答案 0 :(得分:0)
我发现这个关于 R 中承诺和评估的链接有助于解决一个相关问题:https://mailund.dk/posts/promises-and-lazy-evaluation/。我想知道在 build_date_0 = lubridate::today() %>% as.character()
之后是否添加对 build_date_0
的调用是否可以解决承诺?祝你好运!