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

Implement dbWithTransaction #500

Closed
ablack3 opened this issue Jul 18, 2022 · 1 comment
Closed

Implement dbWithTransaction #500

ablack3 opened this issue Jul 18, 2022 · 1 comment
Labels
DBI 🗃️ feature a feature request or enhancement

Comments

@ablack3
Copy link

ablack3 commented Jul 18, 2022

It looks like bigquery supports transactions but bigrquery does not currently support dbWithTransation(). I would like to be able to use DBI::dbWithTransaction with a BigQueryConnection.

For some reason the code below works fine when executed with source but not when executed using the reprex package. I'm not sure why. I've copied the output below the code.

library(bigrquery)
library(DBI)

sql <- "SELECT count(*) AS n FROM `publicdata.samples.natality`"

bigrquery::bq_auth(path = Sys.getenv("BIGQUERY_SERVICE_ACCOUNT_JSON_PATH"))

con <- dbConnect(
  bigrquery::bigquery(),
  project = "publicdata",
  dataset = "samples",
  billing = Sys.getenv("BIGQUERY_TEST_PROJECT")
)

# this works
dbGetQuery(con, sql)
# # A tibble: 1 × 1
# n
# <int>
# 137826763

# this does not work
dbWithTransaction(con, {
  dbGetQuery(con, sql)
})
# Error: Reason: Not yet implemented: dbBegin(Connection)
dbDisconnect(con)

R version 4.2.0
Package versions DBI_1.1.3 bigrquery_1.4.0

@hadley hadley added feature a feature request or enhancement DBI 🗃️ labels Nov 2, 2023
@hadley
Copy link
Member

hadley commented Nov 7, 2023

Now part of #557 since using a transaction requires activating a session.

@hadley hadley closed this as completed Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DBI 🗃️ feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants