- 类别:
系统函数 (系统信息)
SYSTEM$CATALOG_LINK_STATUS¶
返回指定的 目录链接数据库 的链接状态。
语法¶
SYSTEM$CATALOG_LINK_STATUS( '<catalog_linked_db_name>' )
实参¶
'catalog_linked_db_name'指定要检查其状态的目录链接的数据库的名称。
返回¶
该函数返回包含以下名称/值对的 JSON 对象:
{
"executionState":"<value>",
"failedExecutionStateReason":"<value>",
"failedExecutionStateErrorCode":"<value>",
"lastLinkAttemptStartTime":"<value>",
"failureDetails":[
{
"qualifiedEntityName":"<value>",
"entityDomain":"<value>",
"operation":"<value>",
"errorCode":"<value>",
"errorMessage":"<value>"
},
{ ... },
...
]
}
其中:
executionStateSnowflake 用于连接到您的 Iceberg 目录的链接操作的当前执行状态。
值:
RUNNING:下一次表发现同步已安排或正在执行;不能保证所有表都已成功同步。
FAILED: The linking operation encountered an error and was unsuccessful.If the linking operation fails, resolve the error first. Snowflake then automatically schedules the next table discovery sync, unless discovery has been suspended for the catalog-linked database. If you suspended discovery, run ALTER DATABASE ... RESUME DISCOVERY after you resolve the error to resume discovery.
For example:
ALTER DATABASE IF EXISTS my_linked_db RESUME DISCOVERY;failedExecutionStateReasonError message associated with a
FAILEDexecution state. Doesn't appear in the function output if the last sync attempt was successful.failedExecutionStateErrorCode与
FAILED执行状态相关的错误代码。如果上次同步尝试成功,则不会出现在函数输出中。lastLinkAttemptStartTime时间戳,标明 Snowflake 最近一次开始发现和同步远程目录中更改的时间。
failureDetails一个对象数组,提供有关 Snowflake 无法同步的远程目录中实体(例如表)的详细信息。每个对象都具有以下字段:
qualifiedEntityName远程目录中实体相对于目录名称的限定名称。
例如
namespace_level_1.namespace_level_2.table_name。类型:字符串
entityDomain远程目录中的实体域;例如 TABLE。
类型:字符串
operationThe operation in Snowflake associated with the sync; for example,
CREATEa table or schema,DROP.
If the operation is
CATALOG_CONNECTION, there was an error when Snowflake attempted to connect to the remote catalog.If the operation is
DISCOVERY, there was an error when Snowflake attempted to discover the tables or namespaces in your remote catalog. To see which table or namespace caused the error, seeentityDomain, which will either beTABLEorNAMESPACE.类型:字符串
errorCode与失败相关的错误代码。
类型:字符串
errorMessage与失败相关的错误代码。
类型:字符串
访问控制要求¶
用于执行此 SQL 命令的 角色 必须至少具有以下一项 权限:
权限 |
对象 |
|---|---|
OWNERSHIP |
目标目录链接数据库。 |
MONITOR |
目标目录链接数据库。 |
使用说明¶
failureDetails字段返回有关 DROP SCHEMA 和 DROP ICEBERG TABLE 失败的信息。只要您使用对所指定目录链接的数据库具有权限的角色,就会返回结果。有关更多信息,请参阅 数据库权限。
示例¶
检索名为 my_cld 的目录链接的数据库的链接状态:
SELECT SYSTEM$CATALOG_LINK_STATUS('my_cld');
输出:
{
"executionState": "RUNNING",
"lastLinkAttemptStartTime": "2025-02-14T01:35:01.71Z",
"failureDetails": [
{
"qualifiedEntityName": "my_namespace.table_1",
"entityDomain": "TABLE",
"operation": "CREATE",
"errorCode": "0040000",
"errorMessage": "An internal error occurred. Please contact Snowflake support."
},
{
"qualifiedEntityName": "my_namespace.table_2",
"entityDomain": "TABLE",
"operation": "CREATE",
"errorCode": "0040000",
"errorMessage": "An internal error occurred. Please contact Snowflake support."
}
]
}