Using Databricks CLI to work with Databricks system tables

Using Databricks CLI to work with Databricks system tables

The Databricks CLI, released last year, is a versatile tool. With it, you can do everything that is possible via Databricks REST APIs, but it's much easier because the CLI handles authentication, pagination of results, and many other things that could be hard to do correctly on the first attempt. The list of available commands grows as soon as new REST APIs are released.

One of the regular tasks that administrators need to do is enable the new schemas for Databricks system tables—new functionality is released constantly, allowing customers to gain more insights.

With Databricks CLI (+jq) it's very easy to automate the automatic discovery of not-enabled system schemas and enable them - you just need a few simple steps:

  • Configure authentication - the simplest way is to expose an environment variable with the name of a workspace-level authentication profile in ~/.databrickscfg:

export DATABRICKS_CONFIG_PROFILE=...        

  • Retrieve the ID of Unity Catalog metastore attached to the given workspace:

export DB_METASTORE_ID=$(databricks metastores current|jq -r .metastore_id)        

  • Check the list of system schemas available for enablement:

databricks system-schemas list $DB_METASTORE_ID|jq -cr '.[] | select( .state == "AVAILABLE" ) | .schema'        

  • If the list isn't empty, enable all available schemas:

for schema in $(databricks system-schemas list $DB_METASTORE_ID|jq -cr '.[] | select( .state == "AVAILABLE" ) | .schema'); do
  echo "Enabling $schema"
  databricks system-schemas enable $DB_METASTORE_ID $schema
done        

That's all!

And if necessary, we can disable system schemas that we don't need, but this isn't a very frequent operation...

Hi Alex, How frequently schemas are added? And what should be frequency for running this?

Like
Reply

Awesome tips, Alex! I love how easy system tables make it to promote observabilty across workspaces. The Databricks CLI really can do it all!

To view or add a comment, sign in

More articles by Alex Ott

  • Improving GenAI results with DatabricksIQ

    It's quite interesting how DatabricksIQ improves the quality of GenAI output. I played a bit recently with code…

    1 Comment
  • On 3 years at Databricks

    Anniversaries are a good reason to make a stop, look back and reflect on your journey. Time flies fast, and now it's my…

    14 Comments
  • Notes on practical machine learning

    This post was originally published in my blog. It describes my personal observations collected when working on the…

    2 Comments

Explore content categories