적용 대상:
Databricks SQL
Databricks Runtime 17.3 이상
중요합니다
이 기능은 공개 미리 보기로 제공되며 현재 참여 고객에게만 제공됩니다. 미리 보기에 참여하려면 이 양식을 작성하여 제출하세요. 이 기능은 Hive Metastore(HMS) 및 Glue 페더레이션을 사용하여 외부 카탈로그의 연결 끊기만 지원합니다.
이 DROP CONNECTION 명령을 사용하여 Unity 카탈로그에서 외국 카탈로그를 표준 카탈로그로 변환합니다. 연결을 끊은 후 카탈로그는 더 이상 외부 카탈로그에서 외부 테이블을 동기화하지 않습니다. 대신 관리 테이블 또는 외부 테이블을 포함하는 표준 Unity 카탈로그 카탈로그처럼 작동합니다. 이제 카탈로그는 Unity 카탈로그에서 외부용 대신 표준으로 라벨이 지정됩니다. 이 명령은 외부 카탈로그의 테이블에 영향을 주지 않습니다. Unity 카탈로그의 외국 카탈로그에만 영향을 줍니다.
카탈로그에 대한 OWNERMANAGEUSE_CATALOGBROWSE 사용 권한이 필요합니다.
문법
ALTER CATALOG catalog_name DROP CONNECTION { RESTRICT | FORCE }
매개 변수
-
표준 카탈로그로 변환할 외장 카탈로그의 이름입니다.
제한하다
기본 동작
DROP CONNECTION은RESTRICT가 카탈로그에 외부 테이블이나 외부 뷰가 있는 경우 외부 카탈로그를 표준 카탈로그로 변환할 때 실패합니다.외세 테이블을 Unity 카탈로그 관리 테이블 또는 외부 테이블로 업그레이드하려면 외세 테이블을 관리되는 Unity 카탈로그 테이블로 변환 하거나 외세 테이블을 외부 Unity 카탈로그 테이블로 변환을 참조하세요. 외장 보기를 SET 변환하려면 MANAGED(FOREIGN VIEW)를 참조하세요.
포스
DROP CONNECTION에서FORCE는 외부 카탈로그를 표준 카탈로그로 변환할 때 외부 카탈로그에 남아 있는 외부 테이블 또는 뷰를 삭제합니다. 이 명령은 외부 카탈로그의 데이터나 메타데이터를 삭제하지 않으며, 외부 테이블을 만들기 위해 Unity 카탈로그에 동기화된 메타데이터만 삭제합니다.경고
이 명령은 롤백할 수 없습니다. 외산 테이블을 Unity 카탈로그로 다시 페더레이션하려면 외산 카탈로그를 다시 만들어야 합니다.
예시
-- Convert an existing foreign catalog using default RESTRICT behavior
> ALTER CATALOG hms_federated_catalog DROP CONNECTION;
OK
-- Convert an existing foreign catalog using FORCE to drop foreign tables
> ALTER CATALOG hms_federated_catalog DROP CONNECTION FORCE;
OK
-- RESTRICT fails if foreign tables or views exist
> ALTER CATALOG hms_federated_catalog DROP CONNECTION RESTRICT;
[CATALOG_CONVERSION_FOREIGN_ENTITY_PRESENT] Catalog conversion from UC Foreign to UC Standard failed because catalog contains foreign entities (up to 10 are shown here): <entityNames>. To see the full list of foreign entities in this catalog, please refer to the scripts below.
-- FORCE fails if catalog type isn't supported
> ALTER CATALOG redshift_federated_catalog DROP CONNECTION FORCE;
[CATALOG_CONVERSION_UNSUPPORTED_CATALOG_TYPE] Catalog cannot be converted from UC Foreign to UC Standard. Only HMS and Glue Foreign UC catalogs can be converted to UC Standard.
외장 테이블 및 뷰를 확인하기 위한 스크립트
비고
DROP CONNECTION RESTRICT를 사용하기 전에 Unity 카탈로그 REST API와 이러한 Python 스크립트를 사용하여 카탈로그에서 외부 테이블 및 뷰를 확인할 수 있습니다.
페더레이션 카탈로그의 모든 외장 테이블 및 뷰를 나열하는 스크립트:
import requests
def list_foreign_uc_tables_and_views(catalog_name, pat_token, workspace_url):
"""
Lists all foreign tables and views in the specified Unity Catalog.
Args:
catalog_name (str): The name of the catalog to search.
pat_token (str): Personal Access Token for Databricks API authentication.
workspace_url (str): Databricks workspace hostname (e.g., "https://adb-xxxx.x.azuredatabricks.net").
Returns:
list: A list of dictionaries containing information about the foreign tables/views.
"""
base_url = f"{workspace_url}/api/2.1/unity-catalog"
headers = {
"Authorization": f"Bearer {pat_token}",
"Content-Type": "application/json"
}
# Step 1: List all schemas in the catalog (GET request)
schemas_url = f"{base_url}/schemas"
schemas_params = {
"catalog_name": catalog_name,
"include_browse": "true"
}
schemas_resp = requests.get(schemas_url, headers=headers, params=schemas_params)
schemas_resp.raise_for_status()
schemas = schemas_resp.json().get("schemas", [])
schema_names = [schema["name"] for schema in schemas]
result = []
# Step 2: For each schema, list all tables/views and filter (GET request)
for schema_name in schema_names:
tables_url = f"{base_url}/table-summaries"
tables_params = {
"catalog_name": catalog_name,
"schema_name_pattern": schema_name,
"include_manifest_capabilities": "true"
}
tables_resp = requests.get(tables_url, headers=headers, params=tables_params)
tables_resp.raise_for_status()
tables = tables_resp.json().get("tables", [])
for table in tables:
# Use OR for filtering as specified
if (
table.get("table_type") == "FOREIGN"
or table.get("securable_kind") in {
"TABLE_FOREIGN_HIVE_METASTORE_VIEW",
"TABLE_FOREIGN_HIVE_METASTORE_DBFS_VIEW"
}
):
result.append(table.get("full_name"))
return result
# Example usage:
# catalog = "hms_foreign_catalog"
# token = "dapiXXXXXXXXXX"
# workspace = "https://adb-xxxx.x.azuredatabricks.net"
# foreign_tables = list_foreign_uc_tables_and_views(catalog, token, workspace)
# for entry in foreign_tables:
# print(entry)
ACTIVE 프로비저닝 상태에 있는 모든 외장 테이블 및 뷰를 나열하는 스크립트:
import requests
def list_foreign_uc_tables_and_views(catalog_name, pat_token, workspace_url):
"""
Lists all foreign tables and views in the specified Unity Catalog.
Args:
catalog_name (str): The name of the catalog to search.
pat_token (str): Personal Access Token for Databricks API authentication.
workspace_url (str): Databricks workspace hostname (e.g., "https://adb-xxxx.x.azuredatabricks.net").
Returns:
list: A list of dictionaries containing information about the foreign tables/views.
"""
base_url = f"{workspace_url}/api/2.1/unity-catalog"
headers = {
"Authorization": f"Bearer {pat_token}",
"Content-Type": "application/json"
}
# Step 1: List all schemas in the catalog (GET request)
schemas_url = f"{base_url}/schemas"
schemas_params = {
"catalog_name": catalog_name,
"include_browse": "true"
}
schemas_resp = requests.get(schemas_url, headers=headers, params=schemas_params)
schemas_resp.raise_for_status()
schemas = schemas_resp.json().get("schemas", [])
schema_names = [schema["name"] for schema in schemas]
result = []
# Step 2: For each schema, list all tables/views and filter (GET request)
for schema_name in schema_names:
tables_url = f"{base_url}/table-summaries"
tables_params = {
"catalog_name": catalog_name,
"schema_name_pattern": schema_name,
"include_manifest_capabilities": "true"
}
tables_resp = requests.get(tables_url, headers=headers, params=tables_params)
tables_resp.raise_for_status()
tables = tables_resp.json().get("tables", [])
for table in tables:
# Use OR for filtering as specified
if (
table.get("table_type") == "FOREIGN"
or table.get("securable_kind") in {
"TABLE_FOREIGN_HIVE_METASTORE_VIEW",
"TABLE_FOREIGN_HIVE_METASTORE_DBFS_VIEW"
}
):
table_full_name = table.get('full_name')
get_table_url = f"{base_url}/tables/{table_full_name}"
tables_params = {
"full_name": table_full_name,
"include_browse": "true",
"include_manifest_capabilities": "true"
}
table_resp = requests.get(get_table_url, headers=headers, params=tables_params)
table_resp.raise_for_status()
provisioning_info = table_resp.json().get("provisioning_info", dict()).get("state", "")
if provisioning_info == "ACTIVE":
result.append(table_full_name)
return result
# Example usage:
# catalog = "hms_foreign_catalog"
# token = "dapiXXXXXXXXXX"
# workspace = "https://adb-xxxx.x.azuredatabricks.net"
# foreign_tables = list_foreign_uc_tables_and_views(catalog, token, workspace)
# for entry in foreign_tables:
# print(entry)