-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a helper function for connecting to Snowflake. #662
Conversation
ef860bf
to
e82c829
Compare
e82c829
to
2bf7ad0
Compare
Tests are currently failing because we now have both a |
Ah, interesting. From my perspective, I'd say we transition existing |
2bf7ad0
to
425347d
Compare
@simonpcouch Done. |
0cd3170
to
842b08b
Compare
Since we just added snowflake to our CI, should we add a couple of very basic tests? |
47173f0
to
5af2483
Compare
I've added a number of unit tests (and fixed some issues in the process!), but due to the design of the current CI secrets -- which supply entire connection strings -- I can't see an easy way to pass real credentials through the new |
@simonpcouch could you please take a look at how we're managing secrets to see if we could facilitate their use here? |
@@ -35,7 +35,7 @@ getCatalogSchema <- function(conn, catalog_name = NULL, schema_name = NULL) { | |||
#' to aid with performance, as the SQLColumns method is more performant | |||
#' when restricted to a particular DB/schema. | |||
#' @inheritParams DBI::dbListFields | |||
#' @rdname Snowflake | |||
#' @rdname driver-Snowflake |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be tempted to document them alltogether, adding a new section that details the snowflake method variations. But might be easiest for me to do this after the PR is merged.
Just pushed a quick demo of using the secret in tests--fine by me to have both the PWD embedded in a connection string and the PWD itself in the |
quarto render seems to be unable to connect to snowflake. Manually running the code chunk and runnign the code in the console work just fine.
reprex quarto file using the cybersyn webtraffic database: https://docs.cybersyn.com/consumer-insights/web-traffic-foundation
|
In the above, "ambient" credentials are those set by default in the Posit Workbench build hosted at dev palm ptd: grep("SNOWFLAKE", names(Sys.getenv()), value = TRUE)
#> [1] "SNOWFLAKE_ACCOUNT" "SNOWFLAKE_HOME" "SNOWFLAKE_ROLE" If this is just a config issue, we should detect the conditions when this error will be raised and raise a more informative one before dispatching to EDIT: noting that I can reproduce Daniel's issue. |
aec47f3
to
f7de3f4
Compare
This is ready for re-review:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking solid! That Snowflake CI failure for the "real" connection did indeed crop up elsewhere and is uninformative due to #798—no need to address here. I do see, in R CMD check runs:
❯ checking Rd \usage sections ... WARNING
Undocumented arguments in Rd file 'driver-Snowflake.Rd'
‘catalog_name’ ‘schema_name’
Could you look into those?
Submitting review as "Comment" rather than "Approve" only so as to defer to Hadley on the timeline to merge this one. :)
f7de3f4
to
46e0f71
Compare
The warning about missing docs is unrelated to this PR but I fixed it anyway to try and make CI happy :) |
46e0f71
to
beb23cd
Compare
cc @skaltman |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GHA failure:
── Failed tests ────────────────────────────────────────────────────────────────
Error ('test-driver-snowflake.R:2:3'): can connect to snowflake
Error in `test_con("SNOWFLAKE")`: ! ODBC failed with error 00000 from [Snowflake][Snowflake].
* Password not found.
i From 'nanodbc/nanodbc.cpp:1147'.
...is due to the relevant repository secret not being available and is fine to ignore. Game to merge with your thumbs-up, @atheriel—just let us know whether you want to address the warning -> error conversion review comment in this PR or file a separate issue to make that happen.
This commit introduces a new odbc::snowflake() function intended to help setting up connections to Snowflake and handling auth correctly on platforms that provide Snowflake-native OAuth credentials. Due to a naming clash, the Snowflake.Rd file has also been renamed driver-Snowflake.Rd. Because we want to smoke test arguments to the snowflake() function directly rather than a full connection string, this commit also exposes a new environment variable with the GitHub secret for the Snowflake password. Unit tests are included. Signed-off-by: Aaron Jacobs <aaron.jacobs@rstudio.com>
Signed-off-by: Aaron Jacobs <aaron.jacobs@rstudio.com>
Signed-off-by: Aaron Jacobs <aaron.jacobs@rstudio.com>
8a1df83
to
16ef158
Compare
This commit introduces a new
odbc::snowflake()
function intended to help setting up connections to Snowflake and handling auth correctly on platforms that provide Snowflake-native OAuth credentials. It generally follows the pattern established withodbc::databricks()
.We've been testing this internally on Snowflake's container platform, and it works as expected.