Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upMake pool compatible with dbplyr #42
Conversation
| #' @include DBI.R | ||
| NULL | ||
|
|
||
| temporaryErrorMessage <- paste0("You cannot use `temporary = TRUE`", |
hadley
Jun 20, 2017
Member
I think this would be slightly better as checkTemporary(), i.e. including the boilerplate if (temporary) stop(temporaryErrorMessage)
I think this would be slightly better as checkTemporary(), i.e. including the boilerplate if (temporary) stop(temporaryErrorMessage)
hadley
Jun 21, 2017
Member
I have mixed feelings. They feel inelegant to me, but users tend to really appreciate them.
I have mixed feelings. They feel inelegant to me, but users tend to really appreciate them.
| } | ||
|
|
||
| #' @export | ||
| db_create_table.Pool <- function(con, table, types, temporary = FALSE, ...) { |
hadley
Jun 20, 2017
Member
I do wonder about changing the default value of temporary here. Obviously it's going to be annoying if it's TRUE, but it might be surprising if it's FALSE.
I do wonder about changing the default value of temporary here. Obviously it's going to be annoying if it's TRUE, but it might be surprising if it's FALSE.
jcheng5
Jun 20, 2017
Member
Isn't the default always FALSE? Are you wondering about changing the default in dplyr itself?
Isn't the default always FALSE? Are you wondering about changing the default in dplyr itself?
bborgesr
Jun 20, 2017
Author
Contributor
You mean changing it in the original generic in dplyr? Or just here in pool?
You mean changing it in the original generic in dplyr? Or just here in pool?
bborgesr
Jun 20, 2017
Author
Contributor
(sorry Joe, didn't see your comment asking exactly the same thing)
(sorry Joe, didn't see your comment asking exactly the same thing)
hadley
Jun 21, 2017
Member
Isn't the default in the generic TRUE?
Isn't the default in the generic TRUE?
bborgesr
Jun 21, 2017
Author
Contributor
@hadley No: https://github.com/tidyverse/dplyr/blob/master/R/dbplyr.R#L95 Or am I missing something?
@hadley No: https://github.com/tidyverse/dplyr/blob/master/R/dbplyr.R#L95 Or am I missing something?
hadley
Jun 21, 2017
Member
Ok, I was confused. You can ignore this whole thread.
Ok, I was confused. You can ignore this whole thread.
| #' @export | ||
| copy_to.Pool <- function(dest, df, name = deparse(substitute(df)), | ||
| overwrite = FALSE, ...) { | ||
| db_con <- poolCheckout(dest) |
hadley
Jun 20, 2017
Member
I now know how to convert
db_con <- poolCheckout(dest)
on.exit(poolReturn(db_con))
to
db_con <- localPoolCheckout(dest)
with the on.exit() being automatically added.
It's up to you if you'd prefer that API.
I now know how to convert
db_con <- poolCheckout(dest)
on.exit(poolReturn(db_con))to
db_con <- localPoolCheckout(dest)with the on.exit() being automatically added.
It's up to you if you'd prefer that API.
jcheng5
Jun 20, 2017
Member
I find that slightly terrifying
I find that slightly terrifying
|
@hadley, is there anything that you think I may have missed? All I did was a thin Pool wrapper around all the methods for DBIConnection (including
|
| db_con <- poolCheckout(con) | ||
| on.exit(poolReturn(db_con)) | ||
| sql_subquery(db_con, from = from, name = name, ... = ...) | ||
| } |
bborgesr
Jun 21, 2017
Author
Contributor
another worry I have is if this function is amenable to pool. Is the name = random_table_name()'s value actually made into a table using create_table or something?
another worry I have is if this function is amenable to pool. Is the name = random_table_name()'s value actually made into a table using create_table or something?
hadley
Jun 21, 2017
Member
No, it's for databases that require subqueries be named (even if that name isn't actually used for anything).
No, it's for databases that require subqueries be named (even if that name isn't actually used for anything).
|
The 3rd item is optional, so I wouldn't worry about it for now. You should probably also include some basic tests of pool dplyr using RSQLite. |
| db_con <- poolCheckout(con) | ||
| on.exit(poolReturn(db_con)) | ||
| sql_subquery(db_con, from = from, name = name, ... = ...) | ||
| } |
hadley
Jun 21, 2017
Member
No, it's for databases that require subqueries be named (even if that name isn't actually used for anything).
No, it's for databases that require subqueries be named (even if that name isn't actually used for anything).
This comment has been minimized.
This comment has been minimized.
|
This will create |
This comment has been minimized.
This comment has been minimized.
|
warning -> error |
Fixes #39