Skip to content

Basic create-read-update-delete verbs for datasets.

Usage

bq_dataset_create(x, location = "US", ...)

bq_dataset_meta(x, fields = NULL)

bq_dataset_exists(x)

bq_dataset_update(x, ...)

bq_dataset_delete(x, delete_contents = FALSE)

bq_dataset_tables(x, page_size = 50, max_pages = Inf, warn = TRUE, ...)

Arguments

x

A bq_dataset

location

Dataset location

...

Additional arguments passed on to the underlying API call. snake_case names are automatically converted to camelCase.

fields

An optional field specification for partial response

delete_contents

If TRUE, will recursively delete all tables in the dataset. Set to FALSE by default for safety.

page_size

Number of items per page.

max_pages

Maximum number of pages to retrieve. Use Inf to retrieve all pages (this may take a long time!)

warn

If TRUE, warn when there are unretrieved pages.

Google BigQuery API documentation

Examples

ds <- bq_dataset(bq_test_project(), "dataset_api")
bq_dataset_exists(ds)
#> [1] FALSE

bq_dataset_create(ds)
#> <bq_dataset> gargle-169921.dataset_api
bq_dataset_exists(ds)
#> [1] TRUE
str(bq_dataset_meta(ds))
#> List of 10
#>  $ kind            : chr "bigquery#dataset"
#>  $ etag            : chr "k/GaqB32iUpfakA8rV/YMw=="
#>  $ id              : chr "gargle-169921:dataset_api"
#>  $ selfLink        : chr "https://bigquery.googleapis.com/bigquery/v2/projects/gargle-169921/datasets/dataset_api"
#>  $ datasetReference:List of 2
#>   ..$ datasetId: chr "dataset_api"
#>   ..$ projectId: chr "gargle-169921"
#>  $ access          :List of 4
#>   ..$ :List of 2
#>   .. ..$ role        : chr "WRITER"
#>   .. ..$ specialGroup: chr "projectWriters"
#>   ..$ :List of 2
#>   .. ..$ role        : chr "OWNER"
#>   .. ..$ specialGroup: chr "projectOwners"
#>   ..$ :List of 2
#>   .. ..$ role       : chr "OWNER"
#>   .. ..$ userByEmail: chr "bigrquery-testing@gargle-169921.iam.gserviceaccount.com"
#>   ..$ :List of 2
#>   .. ..$ role        : chr "READER"
#>   .. ..$ specialGroup: chr "projectReaders"
#>  $ creationTime    : chr "1710437996132"
#>  $ lastModifiedTime: chr "1710437996132"
#>  $ location        : chr "US"
#>  $ type            : chr "DEFAULT"

bq_dataset_delete(ds)
bq_dataset_exists(ds)
#> [1] FALSE

# Use bq_test_dataset() to create a temporary dataset that will
# be automatically deleted
ds <- bq_test_dataset()
bq_table_create(bq_table(ds, "x1"))
#> <bq_table> gargle-169921.TESTING_mwlefoodfi.x1
bq_table_create(bq_table(ds, "x2"))
#> <bq_table> gargle-169921.TESTING_mwlefoodfi.x2
bq_table_create(bq_table(ds, "x3"))
#> <bq_table> gargle-169921.TESTING_mwlefoodfi.x3
bq_dataset_tables(ds)
#> [[1]]
#> <bq_table> gargle-169921.TESTING_mwlefoodfi.x1
#> 
#> [[2]]
#> <bq_table> gargle-169921.TESTING_mwlefoodfi.x2
#> 
#> [[3]]
#> <bq_table> gargle-169921.TESTING_mwlefoodfi.x3
#>