Categories:

Information Schema , Table functions

APPLICATION_CALLBACK_HISTORY

Returns information about the history of callback invocations for Snowflake Native Apps in your Snowflake account. Each row represents a callback invocation, including the callback type, execution mode, state, and any error information.

语法

APPLICATION_CALLBACK_HISTORY(
  [ APPLICATION_NAME => '<application_name>' ]
  [ , CALLBACK_TYPE => '<callback_manifest_name>' ]
  [ , LIMIT => <number> ]
)

可选实参

APPLICATION_NAME => 'application_name'

要检索其回调历史的应用程序名称。如果未指定,则返回账户中所有应用程序的历史记录。

CALLBACK_TYPE => 'callback_manifest_name'

清单文件中定义的回调类型。如果未指定,则返回指定应用程序中所有回调类型的历史记录。

LIMIT => number

要返回的最大行数。默认值为 100。最大值为 10000。

使用说明

  • When calling an Information Schema table function, the session must have an INFORMATION_SCHEMA schema in use or the function name must be fully-qualified. For more details, see Snowflake Information Schema.
  • The QUERY_TEXT and ERROR_MESSAGE columns are redacted unless the caller is the app itself.
  • 使用此函数需要满足以下条件之一:
    • 应用程序的 OWNERSHIP。
    • 应用程序的 MONITOR 权限。
    • 以应用程序自身的身份运行。

输出

该函数返回以下列:

Column NameData TypeDescription
TYPEVARCHARThe callback type as defined in the manifest file.
EXECUTION_MODEVARCHARThe execution mode of the callback. Possible values are: SYNC, ASYNC.
APPLICATION_NAMEVARCHARThe name of the app that defines the callback.
STATEVARCHARThe state of the callback execution. See 回调状态.
STARTED_ONTIMESTAMP_LTZThe timestamp when the callback was invoked.
COMPLETED_ONTIMESTAMP_LTZThe completion timestamp. NULL if the callback has not yet completed.
TRIGGERING_QUERY_IDVARCHARThe query ID of the SQL statement that triggered the callback. NULL if the callback was not triggered by a SQL query (for example, when triggered after an upgrade completes).
QUERY_IDVARCHARThe query ID of the callback procedure execution. NULL if the callback has not yet completed.
QUERY_TEXTVARCHARThe procedure call SQL text. NULL if the callback has not yet completed. This column is redacted unless the caller is the app itself.
ERROR_CODEVARCHARThe error code. NULL unless STATE is FAILED or ABORTED.
ERROR_MESSAGEVARCHARThe error message. NULL unless STATE is FAILED or ABORTED. This column is redacted unless the caller is the app itself.

回调状态

下表描述了 STATE 列的可能值:

StateApplies toDescription
QUEUEDAsync onlyThe callback is waiting to be scheduled.
SCHEDULEDAsync onlyThe callback has been scheduled and is waiting to be executed.
EXECUTINGAsync / SyncThe callback procedure is currently running.
COMPLETEDAsync / SyncThe callback procedure finished successfully.
FAILEDAsync / SyncThe callback procedure failed validation (for example, wrong signature) or execution.
ABORTEDAsync onlyAn internal scheduling error occurred. This state requires support intervention.

示例

检索特定应用程序的回调历史记录:

SELECT *
FROM TABLE(
    INFORMATION_SCHEMA.APPLICATION_CALLBACK_HISTORY(
        APPLICATION_NAME => 'my_app'));

检索特定回调类型的回调历史记录,并设置自定义限制:

SELECT *
FROM TABLE(
    INFORMATION_SCHEMA.APPLICATION_CALLBACK_HISTORY(
        APPLICATION_NAME => 'my_app',
        CALLBACK_TYPE => 'after_configuration_change',
        LIMIT => 100));