# NOT RUN {
config <- spark_config()
sc <- spark_connect(master = "local", config = config)
bigquery_defaults(
billingProjectId = "<your_billing_project_id>",
gcsBucket = "<your_gcs_bucket>",
datasetLocation = "US",
serviceAccountKeyFile = "<your_service_account_key_file>",
type = "direct")
# Copy mtcars to Spark
spark_mtcars <- dplyr::copy_to(sc, mtcars, "spark_mtcars", overwrite = TRUE)
spark_write_bigquery(
data = spark_mtcars,
datasetId = "<your_dataset_id>",
tableId = "mtcars",
mode = "overwrite")
# }
Run the code above in your browser using DataLab