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

feat(r): Add R BigQuery driver wrapper #2235

Merged
merged 8 commits into from
Oct 9, 2024

Conversation

paleolimbot
Copy link
Member

@paleolimbot paleolimbot commented Oct 8, 2024

This PR adds a BigQuery driver wrapper for R. It is basically the same as the FlightSQL wrapper with the addition of one helper function to take care of the auth (in R we have the lovely gargle package and bigrquery which have extensive methods for handling auth in various scenarios).

I don't think we have a way to get credentials into CI yet (but at least we have build/package load coverage for when that happens).

library(adbcdrivermanager)

# Use the driver manager to connect to a database
db <- adbc_database_init(
  adbcbigquery::adbcbigquery(),
  token = bigrquery::bq_token(),
  "adbc.bigquery.sql.project_id" = Sys.getenv("ADBC_BIGQUERY_TEST_PROJECT_ID")
)
con <- adbc_connection_init(db)

con |>
  read_adbc(
    "SELECT zipcode, latitude, longitude
      FROM `bigquery-public-data.utility_us.zipcode_area` LIMIT 10"
  ) |>
  tibble::as_tibble()
#> # A tibble: 10 × 3
#>    zipcode latitude longitude
#>    <chr>      <dbl>     <dbl>
#>  1 96950       15.2     146. 
#>  2 96952       15.0     146. 
#>  3 96951       14.2     145. 
#>  4 96910       13.5     145. 
#>  5 96929       13.6     145. 
#>  6 96921       13.5     145. 
#>  7 96913       13.5     145. 
#>  8 96932       13.5     145. 
#>  9 50012       42.0     -93.6
#> 10 52352       42.3     -91.8

Created on 2024-10-09 with reprex v2.1.1

@paleolimbot paleolimbot marked this pull request as ready for review October 9, 2024 20:28
@github-actions github-actions bot added this to the ADBC Libraries 15 milestone Oct 9, 2024
@paleolimbot paleolimbot merged commit 352e653 into apache:main Oct 9, 2024
110 checks passed
@paleolimbot paleolimbot deleted the r-driver-bigquery branch October 9, 2024 23:29
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

Successfully merging this pull request may close these issues.

2 participants