cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Delete folder using Databricks CLI

joaogilsa
New Contributor II

Hello,

I am trying to delete a folder and its content using databricks cli, but I'm getting the following error:

databricks workspace delete /Workspace/Users/XXX/XXX --profile DEFAULT --recursive true
Error: expected to have the absolute path of the notebook or directory

I have tried deleting a single file, and it's working. It's only when I try to delete a folder that it fails.

Thank you in advance!

1 ACCEPTED SOLUTION

Accepted Solutions

szymon_dybczak
Esteemed Contributor III

Hi @joaogilsa ,

Delete true after recursive and it should work ๐Ÿ˜€ Look at below help output. It looks like that recursive it's already boolean flag, so when you add true I think it has problem with parsing:

Delete a workspace object.
  
  Deletes an object or a directory (and optionally recursively deletes all
  objects in the directory). * If path does not exist, this call returns an
  error RESOURCE_DOES_NOT_EXIST. * If path is a non-empty directory and
  recursive is set to false, this call returns an error
  DIRECTORY_NOT_EMPTY.
  
  Object deletion cannot be undone and deleting a directory recursively is not
  atomic.

  Arguments:
    PATH: The absolute path of the notebook or directory.

Usage:
  databricks workspace delete PATH [flags]

Flags:
  -h, --help        help for delete
      --json JSON   either inline JSON string or @path/to/file.json with request body (default JSON (0 bytes))
      --recursive   The flag that specifies whether to delete the object recursively.

View solution in original post

3 REPLIES 3

szymon_dybczak
Esteemed Contributor III

Hi @joaogilsa ,

Delete true after recursive and it should work ๐Ÿ˜€ Look at below help output. It looks like that recursive it's already boolean flag, so when you add true I think it has problem with parsing:

Delete a workspace object.
  
  Deletes an object or a directory (and optionally recursively deletes all
  objects in the directory). * If path does not exist, this call returns an
  error RESOURCE_DOES_NOT_EXIST. * If path is a non-empty directory and
  recursive is set to false, this call returns an error
  DIRECTORY_NOT_EMPTY.
  
  Object deletion cannot be undone and deleting a directory recursively is not
  atomic.

  Arguments:
    PATH: The absolute path of the notebook or directory.

Usage:
  databricks workspace delete PATH [flags]

Flags:
  -h, --help        help for delete
      --json JSON   either inline JSON string or @path/to/file.json with request body (default JSON (0 bytes))
      --recursive   The flag that specifies whether to delete the object recursively.

joaogilsa
New Contributor II

Thank you for the help, @szymon_dybczak, it worked!

szymon_dybczak
Esteemed Contributor III

Cool, glad that it worked ๐Ÿ™‚

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now