Searching for Tables By Custom Field
Sometimes we need a way to find Data Sources, Schemas, Tables, or Columns/attributes through a custom field vs by name. There is an easy way to do this with the Relational Get APIs. This API has a lot of power and flexibility.
In the below example, let's assume that we are looking for all tables in the catalog that have been labeled "Secret" for the custom metadata field "Data Classification". Per the documentation, we need to specify which object type we're looking for, in this case a table.
import requests
# setting the base_url so that all we need to do is swap API endpoints
base_url = "CHANGEME"
# api access key
api_key = "CHANGEME"
# setting up this access key to be in the headers
headers = {"token": api_key}
# api for the relational api endpoint
relational_api = "/catalog/table?custom_fields=[{"field_name":"Data Classification", "value":"Secret"}]
# controlling how many objects come back.
# Check the response headers for "X-Next-Page". If it is present
# then it will have a URL for the next set of results.
limit = "&limit=100"
# make the API call
res = requests.get(base_url + relational_api + limit , headers=headers)
# convert the response to a python dict.
found_tables = res.json()
print(
Updated 12 months ago