Skip to content
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

Warning: <JDBCConnection> uses an old dbplyr interface #173

Closed
nviraj opened this issue Sep 3, 2023 · 5 comments
Closed

Warning: <JDBCConnection> uses an old dbplyr interface #173

nviraj opened this issue Sep 3, 2023 · 5 comments

Comments

@nviraj
Copy link

nviraj commented Sep 3, 2023

Hi,
Thank you for the excellent package. Very useful and much appreciated.

I am using “pool” with “RJDBC” and “dbplyr” packages to connect to Athena tables.
However I see the following warning.

Warning: <JDBCConnection> uses an old dbplyr interface
ℹ Please install a newer version of the package or contact the maintainer

Initially I thought it had something to do with RJDBC but it does not seem to be the case, as seen here.

I don't have a reproducible example due to the private nature of the databases I am connecting to, but the issue might be originating from Pool instead.
Interestingly the example at the end of this reference page has the same warning, which is how I tracked it in spite of the misleading warning.

#> Warning: <Pool> uses an old dbplyr interface
#> ℹ Please install a newer version of the package or contact the maintainer
#> This warning is displayed once every 8 hours.

Please let me know if you need any further details. Thanks!

@hadley
Copy link
Member

hadley commented Sep 3, 2023

That was fixed in the last version of pool; you might need to upgrade.

@hadley hadley closed this as completed Sep 3, 2023
@nviraj
Copy link
Author

nviraj commented Sep 4, 2023

Thanks for your response Hadley. I am already using pool 1.0.1.

Managed to get a reprex using PostgreSQL Docker and JDBC. Please let me know if I am doing something incorrectly or need to report this elsewhere.

Steps to reproduce:

1. Create docker image to connect to using the official image:
docker run --network=host --name postgresdb_reprex -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_USER=postgres -d postgres

2. Download JAR file from here
Alternatively you can use the attached Project which contains the script and the JAR file for Windows.
pool_issue.zip

3. Run reprex code
reprex.R contains the actual code. Running through
reprex::reprex(input = "reprex.R", venue = "gh", session_info = TRUE)

Reprex Content:

library(DBI)
#> Warning: package 'DBI' was built under R version 4.3.1
library(pool)
#> Warning: package 'pool' was built under R version 4.3.1
library(dplyr)
#> Warning: package 'dplyr' was built under R version 4.3.1
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(RJDBC)
#> Warning: package 'RJDBC' was built under R version 4.3.1
#> Loading required package: rJava

# Connection details for docker image of postgres
connection_url <- "jdbc:postgresql://localhost:5432/postgres"
username <- "postgres"
password <- "mysecretpassword"
# Where is the JAR file stored
# JDBC downloaded through https://jdbc.postgresql.org/download/
jdbc_path <- "postgresql-42.6.0.jar"

# Create a JDBC driver
driver <-
  RJDBC::JDBC(
    driverClass = "org.postgresql.Driver",
    classPath = jdbc_path,
    identifier.quote = "'"
  )

# Establish connection through DBI
conn <- DBI::dbConnect(driver, connection_url,
  user = username,
  password = password
)
# Write table to database using DBI
if (!DBI::dbExistsTable(conn, "mtcars")) {
  DBI::dbWriteTable(conn, "mtcars", mtcars)
} else {
  base::message("Table already exists!")
}

# Create a Pool connection
con <- pool::dbPool(
  drv = driver, url = connection_url,
  user = username,
  password = password
)

# Connect to table
mtcars_db <- dplyr::tbl(con, "mtcars")
#> Warning: <JDBCConnection> uses an old dbplyr interface
#> ℹ Please install a newer version of the package or contact the maintainer
#> This warning is displayed once every 8 hours.

# Run sample query
mtcars_db %>%
  dplyr::filter(cyl == 8) %>%
  utils::head()
#> # Source:   SQL [6 x 11]
#> # Database: JDBCConnection
#>     mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb
#>   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1  18.7     8  360    175  3.15  3.44  17.0     0     0     3     2
#> 2  14.3     8  360    245  3.21  3.57  15.8     0     0     3     4
#> 3  16.4     8  276.   180  3.07  4.07  17.4     0     0     3     3
#> 4  17.3     8  276.   180  3.07  3.73  17.6     0     0     3     3
#> 5  15.2     8  276.   180  3.07  3.78  18       0     0     3     3
#> 6  10.4     8  472    205  2.93  5.25  18.0     0     0     3     4

Created on 2023-09-04 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.0 (2023-04-21 ucrt)
#>  os       Windows 11 x64 (build 22621)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_India.utf8
#>  ctype    English_India.utf8
#>  tz       Asia/Calcutta
#>  date     2023-09-04
#>  pandoc   3.1.1 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version date (UTC) lib source
#>    blob          1.2.4   2023-03-17 [1] CRAN (R 4.3.1)
#>    cli           3.6.1   2023-03-23 [1] CRAN (R 4.3.1)
#>    DBI         * 1.1.3   2022-06-18 [1] CRAN (R 4.3.1)
#>    dbplyr        2.3.3   2023-07-07 [1] CRAN (R 4.3.1)
#>    digest        0.6.33  2023-07-07 [1] CRAN (R 4.3.1)
#>    dplyr       * 1.1.2   2023-04-20 [1] CRAN (R 4.3.1)
#>    evaluate      0.21    2023-05-05 [1] CRAN (R 4.3.1)
#>    fansi         1.0.4   2023-01-22 [1] CRAN (R 4.3.1)
#>    fastmap       1.1.1   2023-02-24 [1] CRAN (R 4.3.1)
#>    fs            1.6.3   2023-07-20 [1] CRAN (R 4.3.1)
#>    generics      0.1.3   2022-07-05 [1] CRAN (R 4.3.1)
#>    glue          1.6.2   2022-02-24 [1] CRAN (R 4.3.1)
#>    htmltools     0.5.6   2023-08-10 [1] CRAN (R 4.3.1)
#>    knitr         1.43    2023-05-25 [1] CRAN (R 4.3.1)
#>    later         1.3.1   2023-05-02 [1] CRAN (R 4.3.1)
#>    lifecycle     1.0.3   2022-10-07 [1] CRAN (R 4.3.1)
#>    magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.3.1)
#>    pillar        1.9.0   2023-03-22 [1] CRAN (R 4.3.1)
#>    pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.3.1)
#>    pool        * 1.0.1   2023-02-21 [1] CRAN (R 4.3.1)
#>    purrr         1.0.2   2023-08-10 [1] CRAN (R 4.3.1)
#>    R.cache       0.16.0  2022-07-21 [1] CRAN (R 4.3.1)
#>    R.methodsS3   1.8.2   2022-06-13 [1] CRAN (R 4.3.0)
#>    R.oo          1.25.0  2022-06-12 [1] CRAN (R 4.3.0)
#>    R.utils       2.12.2  2022-11-11 [1] CRAN (R 4.3.1)
#>    R6            2.5.1   2021-08-19 [1] CRAN (R 4.3.1)
#>    Rcpp          1.0.11  2023-07-06 [1] CRAN (R 4.3.1)
#>    reprex        2.0.2   2022-08-17 [1] CRAN (R 4.3.1)
#>  D rJava       * 1.0-6   2021-12-10 [1] CRAN (R 4.3.0)
#>    RJDBC       * 0.2-10  2022-03-24 [1] CRAN (R 4.3.1)
#>    rlang         1.1.1   2023-04-28 [1] CRAN (R 4.3.1)
#>    rmarkdown     2.24    2023-08-14 [1] CRAN (R 4.3.1)
#>    rstudioapi    0.15.0  2023-07-07 [1] CRAN (R 4.3.1)
#>    sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.3.1)
#>    styler        1.10.2  2023-08-29 [1] CRAN (R 4.3.1)
#>    tibble        3.2.1   2023-03-20 [1] CRAN (R 4.3.1)
#>    tidyselect    1.2.0   2022-10-10 [1] CRAN (R 4.3.1)
#>    utf8          1.2.3   2023-01-31 [1] CRAN (R 4.3.1)
#>    vctrs         0.6.3   2023-06-14 [1] CRAN (R 4.3.1)
#>    withr         2.5.0   2022-03-03 [1] CRAN (R 4.3.1)
#>    xfun          0.40    2023-08-09 [1] CRAN (R 4.3.1)
#>    yaml          2.3.7   2023-01-23 [1] CRAN (R 4.3.0)
#> 
#>  [1] C:/Users/viraj/AppData/Local/R/win-library/4.3
#>  [2] C:/Program Files/R/R-4.3.0/library
#> 
#>  D ── DLL MD5 mismatch, broken installation.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

4. Stop and remove Docker image

docker stop postgresdb_reprex
docker rm -f postgresdb_reprex

@hadley
Copy link
Member

hadley commented Sep 4, 2023

Can you confirm that you don't see the error if you connect directly without using pool? It's possible that this is a dbplyr bug.

Also, have you tried using RPostgres instead? That's likely to be faster, easier to set up, and less error prone.

@nviraj
Copy link
Author

nviraj commented Sep 5, 2023

My use case is with Athena tables. It was easier to generate a reprex with PostgreSQL to test RJDBC + pool + dbplyr and rule out anything with the Database JDBC as well.
RAthena exists but has other Python dependencies which I'd like to avoid.

You are right! I just ran the above tbl + filter code using the DBI connection instead of pool and it shows the same warning.

@hadley
Copy link
Member

hadley commented Sep 5, 2023

In that case, can you please file a reprex at https://github.com/tidyverse/dbplyr/issues. Thanks for continuing to investigate this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants