Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2024 12:35 AM
Hi @noorbasha534,
You can query system.access.audit table:
%sql
SELECT request_params.full_name_arg AS table_Name, COUNT(*) AS table_usage
FROM
system.access.audit
WHERE
action_name = 'getTable'
GROUP BY
table_name
ORDER BY
table_usage DESCThe table is in preview not enabled by default. To enable you need to send API call:
# Import necessary libraries
import requests
# Define the necessary variables
workspace_url = "<workspace_url>"
metastore_id = "metastore_id"
schema_name = "access"
pat_token = "pat_token"
# Construct the URL for the API request
url = f"https://{workspace_url}/api/2.0/unity-catalog/metastores/{metastore_id}/systemschemas/{schema_name}"
# Set the headers for the HTTP request
headers = {
"Authorization": f"Bearer {pat_token}"
}
# Make the PUT request to enable access
response = requests.put(url, headers=headers)
# Check the response status
if response.status_code == 200:
print(f"Access successfully enabled for schema `{schema_name}`.")
elif response.status_code == 401:
print("Authorization failed. Please check your PAT token.")
else:
print(f"Failed to enable access: {response.status_code} - {response.text}")