r-dbi / odbc

Connect to ODBC databases (using the DBI interface)
https://odbc.r-dbi.org/
Other
387 stars 107 forks source link

DBI::dbConnect + odbc::databricks(): DATABRICKS_HOST value issue #827

Closed KoderKow closed 1 week ago

KoderKow commented 2 months ago

I am working in Posit Workbench. In my .Renviron file I have DATABRICKS_HOST=https://{my_url}.azuredatabricks.net/. Having a trailing forward slash results in an error.

- Project '~/projects/{my_project}' loaded. [renv 1.0.7]
- One or more packages recorded in the lockfile are not installed.
- Use `renv::status()` for more details.
> con <- DBI::dbConnect(
+   odbc::databricks(),
+   httpPath = "{dbx_httPath}"
+ )
Error in `DBI::dbConnect()`:
! ODBC failed with error 00000 from [RStudio][ThriftExtension].
✖  (14) Unexpected response from server during a HTTP connection: Could not resolve host for client socket..
ℹ From nanodbc/nanodbc.cpp:1150.
Run `rlang::last_trace()` to see where the error occurred.

The error is not very helpful to me in this situation. If I remove the trailing forward slash it works fine.

Restarting R session...

- Project '~/projects/{my_project}' loaded. [renv 1.0.7]
- One or more packages recorded in the lockfile are not installed.
- Use `renv::status()` for more details.
> con <- DBI::dbConnect(
+   odbc::databricks(),
+   httpPath = "{dbx_httPath}"
+ )

Can we get a clearer error code or maybe something in the code that will clean up trailing forward slashes in this situation? This environment variable works perfectly fine in other Databricks functions.

Session Info ```r devtools::session_info() ─ Session info ──────────────────────────────────────────────────────────────────────────────────────────────────── setting value version R version 4.2.1 (2022-06-23 ucrt) os Windows 10 x64 (build 19045) system x86_64, mingw32 ui RStudio language (EN) collate English_United States.utf8 ctype English_United States.utf8 tz America/Chicago date 2024-07-08 rstudio 2024.04.1+748 Chocolate Cosmos (desktop) pandoc NA ─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────────────── ! package * version date (UTC) lib source anytime 0.3.9 2020-08-27 [1] CRAN (R 4.2.3) backports 1.4.1 2021-12-13 [1] CRAN (R 4.2.0) brio 1.1.4 2023-12-10 [1] CRAN (R 4.2.3) cachem 1.0.8 2023-05-01 [1] CRAN (R 4.2.3) checkmate 2.3.1 2023-12-04 [1] CRAN (R 4.2.3) cli 3.6.2 2023-12-11 [1] CRAN (R 4.2.3) crayon 1.5.2 2022-09-29 [1] CRAN (R 4.2.3) P DBI 1.2.2 2024-02-16 [?] CRAN (R 4.2.1) P dbplyr 2.4.0 2023-10-26 [?] RSPM (R 4.2.0) devtools * 2.4.5 2022-10-11 [1] CRAN (R 4.2.3) digest 0.6.34 2024-01-11 [1] CRAN (R 4.2.3) dplyr 1.1.4 2023-11-17 [1] CRAN (R 4.2.3) ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.2.3) fansi 1.0.6 2023-12-08 [1] CRAN (R 4.2.3) fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.2.3) P fs 1.6.3 2023-07-20 [?] RSPM (R 4.2.0) generics 0.1.3 2022-07-05 [1] CRAN (R 4.2.3) glue 1.7.0 2024-01-09 [1] CRAN (R 4.2.3) htmltools 0.5.7 2023-11-03 [1] CRAN (R 4.2.3) htmlwidgets 1.6.4 2023-12-06 [1] CRAN (R 4.2.3) httpuv 1.6.14 2024-01-26 [1] CRAN (R 4.2.3) later 1.3.2 2023-12-06 [1] CRAN (R 4.2.3) lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.2.3) lubridate 1.9.3 2023-09-27 [1] CRAN (R 4.2.3) magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.3) memoise 2.0.1 2021-11-26 [1] CRAN (R 4.2.3) mime 0.12 2021-09-28 [1] CRAN (R 4.2.0) miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.2.3) pillar 1.9.0 2023-03-22 [1] CRAN (R 4.2.3) P pkgbuild 1.4.4 2024-03-17 [?] RSPM (R 4.2.0) pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.2.3) pkgload 1.3.4 2024-01-16 [1] CRAN (R 4.2.3) profvis 0.3.8 2023-05-02 [1] CRAN (R 4.2.3) promises 1.2.1 2023-08-10 [1] CRAN (R 4.2.3) purrr 1.0.2 2023-08-10 [1] CRAN (R 4.2.3) R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.3) Rcpp 1.0.12 2024-01-09 [1] CRAN (R 4.2.3) remotes 2.4.2.1 2023-07-18 [1] CRAN (R 4.2.3) P renv 1.0.7 2024-04-11 [?] RSPM (R 4.2.0) P rlang 1.1.3 2024-01-10 [?] CRAN (R 4.2.3) rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.2.3) sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.3) shiny 1.8.0 2023-11-17 [1] CRAN (R 4.2.3) stringi 1.8.3 2023-12-11 [1] CRAN (R 4.2.3) stringr 1.5.1 2023-11-14 [1] CRAN (R 4.2.3) P testthat 3.2.1 2023-12-02 [?] CRAN (R 4.2.3) tibble 3.2.1 2023-03-20 [1] CRAN (R 4.2.3) tidyr 1.3.1 2024-01-24 [1] CRAN (R 4.2.3) P tidyselect 1.2.1 2024-03-11 [?] RSPM (R 4.2.0) timechange 0.3.0 2024-01-18 [1] CRAN (R 4.2.3) tsibble 1.1.4 2024-01-29 [1] CRAN (R 4.2.3) urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.2.3) P usethis * 2.2.3 2024-02-19 [?] RSPM (R 4.2.0) utf8 1.2.4 2023-10-22 [1] CRAN (R 4.2.3) vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.2.3) xtable 1.8-4 2019-04-21 [1] CRAN (R 4.2.3) [1] C:/Users/{me}/AppData/Local/R/cache/R/renv/library/{my_project}-b8249dca/R-4.2/x86_64-w64-mingw32 [2] C:/Users/{me}/AppData/Local/R/cache/R/renv/sandbox/R-4.2/x86_64-w64-mingw32/0cdf27ab P ── Loaded and on-disk path mismatch. ```
simonpcouch commented 1 week ago

Yikes, that's an unhelpful error message. Just confirming that I can reproduce both the error and the removal of the trailing slash resolving the error.