# NOT RUN {
if (bq_testable()) {
# Querying a project requires full name in query
tb <- bq_project_query(
bq_test_project(),
"SELECT count(*) FROM publicdata.samples.natality"
)
bq_table_fields(tb)
bq_table_download(tb)
# Querying a dataset sets default dataset so you can use bare table name,
# but for public data, you'll need to set a project to bill.
ds <- bq_dataset("publicdata", "samples")
tb <- bq_dataset_query(ds,
query = "SELECT count(*) FROM natality",
billing = bq_test_project()
)
bq_table_download(tb)
tb <- bq_dataset_query(ds,
query = "SELECT count(*) FROM natality WHERE state = @state",
parameters = list(state = "KS"),
billing = bq_test_project()
)
bq_table_download(tb)
}
# }
Run the code above in your browser using DataLab