I want to use dbplyr
to define a hand-written SQL query rather than a table. How can I do that?
For example, I would like to do something like this:
my_custom_sql_tbl <- tbl( con, "SELECT * FROM MY_DATABASE_TABLE WHERE FOO IS NULL" )
my_custom_sql_tbl %>% select( my_columns )
The variable my_custom_sql_tbl
would now act as a tbl(...)
in R, but it would have
custom SQL code running underneath.
Obviously, I intend to have more interesting/complicated SQL than
the things I could easily do in dbplyr.
I tried the above, but it didn't work. It returns an error of "table or view does not exist" or "identifier is too long".
Any suggestions?