Skip to content

How to overwrite existing sheet? #12

@oleg-agapov

Description

@oleg-agapov

Like title says, I want to be able to overwrite existing sheet with data.
I tried add SaveMode, but no effect:

df
  .write
  .mode(SaveMode.Overwrite)
  .format("com.github.potix2.spark.google.spreadsheets")
  .option("serviceAccountId", gserviceAccount)
  .option("credentialPath", pathToP12)
  .save(spreadsheetsId + "/newWorksheet")

I'm getting permission error:

Exception in thread "main" com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "message" : "Invalid requests[0].addSheet: A sheet with the name \"newWorksheet\" already exists. Please enter another name.",
    "reason" : "badRequest"
  } ],
  "message" : "Invalid requests[0].addSheet: A sheet with the name \"newWorksheet\" already exists. Please enter another name.",
  "status" : "INVALID_ARGUMENT"
}

How can I overcome this? I'm using version 0.4.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions