Databricks workspace list command to list subdirectories and it's content recursively

Open
#3,619 5 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
go, shell
Domain
cli

Research direction

Start with the databricks workspace list command and inspect how its current output represents workspace entries. Confirm the expected recursive behavior against a workspace containing nested directories, then make the command list every subdirectory and its contents while preserving the entry details shown by the existing command.

Written by the indexing model from the issue text.

Description

CLI Enhancement

It's not an issue but a feature request may be. We were trying to use Databricks workspace list command to list all content of the folder in the workspace. However, it seems like there is no option to list all subfolders and their contents.

So we used below shell script to achieve the result:

list_recursive() {
local path = "$1"
databricks workspace list "$path" | tail -n +2 | while read id type lang path ; do
    if [[ -z "$path" ]] ; then
        path = "$lang"
        lang = ""
    fi
    echo "ID: $id | Type: $type | Language: $lang | Path: $path"
    if [[ "$type" = = "DIRECTORY" ]] ; then
        list_recursive "$path"
    fi
done
}
for folder in $DATABRICKS_FOLDERS ; do
    path = "$(DATABRICKS_DST_ROOT)/$folder"
    echo "Listing: $path"
    list_recursive "$path"
done
Dominant language
Go
Stars
427
Forks
267
Avg merge
2d 1h
Merged PRs (30d)
233

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from databricks/cli

All issues in databricks/cli

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.