This is basically copying the @mratford approach to reauthenticating an s3 object and applying it to an MoJAthenaConnection. I've stopped short of automatically refreshing credentials, since I'm not 100% sure that's a good idea for database connections, but it does now work. (It's easier in Rdbtools since we're already using an S4 object with environments for slots, so no closures required.)
The key thing is that you have to reauthenticate with the same session name, otherwise you lose access to any tables created under that session name. I can't find good documentation on this, but it does seem to work!
This is basically copying the @mratford approach to reauthenticating an s3 object and applying it to an MoJAthenaConnection. I've stopped short of automatically refreshing credentials, since I'm not 100% sure that's a good idea for database connections, but it does now work. (It's easier in Rdbtools since we're already using an S4 object with environments for slots, so no closures required.)
The key thing is that you have to reauthenticate with the same session name, otherwise you lose access to any tables created under that session name. I can't find good documentation on this, but it does seem to work!