When using the dplyr
package to manipulate tables in a database, it creates a sql statement that can be viewed by the show_query
function. This sql statement is not executed except if you call head
, compute
, collect
or collapse
. In some cases, the sql statement generated by dplyr
is more important than its execution (for example: to create functions for operations not yet implemented in some database packages, like copy (subquery) into file_name;
)
I want to know: how do I get the sql created by dplyr
and put it in a string?
Ok. Looking into dbplyr
source, I found that dbplyr::sql_render
return the table sql statement, which can be used to compound another sql:
sql_query = dbplyr::sql_render(tbl_table)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With