moj-analytical-services / Rdbtools

Accessing Athena on the Analytical Platform
Other
4 stars 0 forks source link

Add temp default schema #23

Closed pjrh-moj closed 1 year ago

pjrh-moj commented 1 year ago

This PR allows the user to set the default database of the Athena connection object to be their temporary database (and it is created if required). This is useful for places where the temporary keyword doesn't work (anything not using DBI under the hood), because then the temp database is used if nothing else is specified. This has made using dbplyr much easier for me, reducing the number of manual string substitutions I was doing.

There only file which has changed code is R/athena_connection.R, the rest is all documentation changes.

There is one additional argument to connect_athena which can now be run as so: con <- connect_athena(schema_name = "__temp__") which sets the default database to be the user's temp db, which is based on their AWS userid.

pjrh-moj commented 1 year ago

@andreassoteriadesmoj - also interested if this would be useful for you, as it is another option to make an issue easier which you raised a while back - https://asdslack.slack.com/archives/C1PUCG719/p1652105852849949

This would allow you to use dbplyr verbs like tbl and compute with the temp database without having to do any string manipulations.

pjrh-moj commented 1 year ago

Ah yes - actually schema_name argument has been set to "default" the whole time and I don't think anyone has asked about it (it's set to "default" by default in the underlying Noctua package - https://github.com/DyfanJones/noctua/blob/ff20ac84dde2663a2108a31dda1964ee125e9952/R/Driver.R#L176)

So the default behaviour isn't changing.

And there is a database called "default" on the AP, filled with bits that people have put there... I've not investigated very much.