KarenZak
New Contributor II

To check if a job cluster is Unity catalog enabled in Databricks programmatically using Python, you can use the Databricks REST API. Here's an example of how you can do it:

Import the required modules:

import requests

Set up the necessary variables:
host_name = "<your_databricks_host_name>"
job_id = "<your_job_id>"
token = "<your_databricks_personal_access_token>"
Send a GET request to the Jobs API to retrieve the job details:
url = f"https://{host_name}/api/2.0/jobs/get?job_id={job_id}"
headers = {"Authorization": f"Bearer {token}"}
response = requests.get(url, headers=headers)
job_details = response.json()
Extract the cluster ID from the job details:
cluster_id = job_details["settings"]["existing_cluster_id"]
Send another GET request to the Clusters API to retrieve the cluster details:
url = f"https://{host_name}/api/2.0/clusters/get?cluster_id={cluster_id}"
response = requests.get(url, headers=headers)
cluster_details = response.json()
Check if Unity catalog is enabled for the cluster:
unity_catalog_enabled = cluster_details["cluster_source"]["unity_catalog_enabled"]
Print the result:
if unity_catalog_enabled:
print("Unity catalog is enabled for the job cluster.")
else:
print("Unity catalog is not enabled for the job cluster.")

Make sure to replace <your_databricks_host_name>, <your_job_id>, and <your_databricks_personal_access_token> with your actual values.

Please note that you need the appropriate permissions and a valid personal access token to access the Databricks REST API.