DBT_PROJECT_EXECUTION_HISTORY
functionsupportedContainer services & dev toolingReturns the execution history of dbt Projects on Snowflake. Call this function to get metadata and results from past dbt Project executions within seven days of the current time. Optionally, specify the values to filter the results by. Use this function with the following system functions to access dbt artifacts and logs programmatically: - SYSTEM$GET_DBT_LOG - SYSTEM$LOCATE_DBT_ARCHIVE - SYSTEM$LOCATE_DBT_ARTIFACTS For more information, see Access dbt artifacts and logs programmatically.
Syntax
supportedpartialnot supportednot scored
DBT_PROJECT_EXECUTION_HISTORY (
[ OBJECT_NAME => '<name>' ]
[ , OBJECT_TYPE = { WORKSPACE | DBT PROJECT }]
[ , START_TIME_RANGE_START => <start_time> ]
[ , START_TIME_RANGE_END => <end_time> ]
[ , RESULT_LIMIT = <integer> ]
[ , COMMAND = <dbt_command> ]
[ , USER_NAME = <user_name> ]
[ , DATABASE = <db_name> ]
[ , SCHEMA = <schema_name> ]
)
Parameters
| Name | Required | Description |
|---|---|---|
OBJECT_NAME = <name> | required | Name of the workspace or dbt project object that the execution belongs to. In addition, the identifier must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (for example, "My object"). Identifiers enclosed in double quotes are also case-sensitive. For more information, see Identifier requirements. |
OBJECT_TYPE = { WORKSPACE | DBT PROJECT } | required | The type of the object, WORKSPACE or DBT PROJECT, the execution belongs to. |
START_TIME_RANGE_START | START_TIME_RANGE_END = timestamp | required | Timestamp to filter a range of executions. |
RESULT_LIMIT = integer | required | An integer specifying the maximum number of rows returned by the function, from 1 - 10,000 inclusive. Default: 100 |
COMMAND = dbt_command | required | Specifies the dbt command used to execute the dbt project object. |
USER_NAME = user_name | required | Name of the user that initiated the dbt project object execution. |
DATABASE = db_name | required | Return only records for the specified database. |
SCHEMA = schema_name | required | Return only records for the specified schema. |
Usage notes
- Use the exact dbt project object name (case-sensitive if created with quotes). If no row matches (wrong name or no executions yet), you might get an Inputs may not be null. error.
- Use function arguments such as DATABASE, SCHEMA, and OBJECT_NAME to filter results whenever possible. These filters are applied before the RESULT_LIMIT (default: 100 rows), so using them ensures you get the most relevant results rather than filtering a potentially truncated result set with a WHERE clause.
Output
The function returns the following columns. To view these columns, you must use a role with the MONITOR privilege. Column Name | Data Type | Description QUERY_ID | TEXT | ID of the query. QUERY_START_TIME | TIMESTAMP_LTZ | The time the query started. QUERY_END_TIME | TIMESTAMP_LTZ | The time the query ended. For an execution that is still running (STATE is RUNNING), this column doesn’t contain a valid end time. USER_NAME | TEXT | The user that ran the execution. OBJECT_NAME | TEXT | Name of the workspace or dbt project object the execution belonged to. OBJECT_TYPE | TEXT | Type of object, such as WORKSPACE or DBT PROJECT. DATABASE_NAME | TEXT | Database of the object. SCHEMA_NAME | TEXT | Schema of the object. COMMAND | TEXT | The command that was run for the object. ARGS | TEXT | The arguments that were used in the run for the object. ERROR_CODE | TEXT | If applicable, the error code for the run. ERROR_MESSAGE | TEXT | If applicable, error message stating why the run failed. WAREHOUSE | TEXT | Warehouse used for the object. STATE | TEXT | State of the run. One of the following values: RUNNING: The execution is in progress. SUCCESS: The dbt command completed successfully. HANDLED_ERROR: The dbt command ran but reported a failure, such as a failed model or test. UNHANDLED_ERROR: The execution failed before completing all of its models or tests, for example because the query was canceled or the profiles.yml file is invalid.The distinction between HANDLED_ERROR and UNHANDLED_ERROR applies only to dbt 1.x projects. For dbt 2.x projects, a failed execution is reported as HANDLED_ERROR, even if it fails before running any models or tests (for example, because the dbt_project.yml file is invalid). DBT_VERSION | TEXT | The version of dbt Core used to run the project, such as 1.9.4. This is the version of the dbt engine, not a version of your dbt project. DBT_SNOWFLAKE_VERSION | TEXT | The version of the dbt-snowflake adapter package used for the run, such as 1.9.2. This is not a version of your dbt project. ENVIRONMENT | TEXT | The environment (defined in the env.yml file) used for this run. NULL if the run didn’t use an environment. For more information, see Use SQL environment variables and private Git packages. WRITEBACK | BOOLEAN | Whether the run wrote its generated target and log files back to the live version of the dbt project object. This is the effective value for the run: the WRITEBACK value specified in EXECUTE DBT PROJECT if present; otherwise, the object’s DEFAULT_WRITEBACK value. TARGET_PATH | TEXT | The dbt target directory used for the run, relative to the dbt project root, such as target. Reflects the --target-path flag or a target path environment variable, such as DBT_TARGET_PATH, if set; otherwise, the dbt default. NULL if the path wasn’t recorded for the run. LOG_PATH | TEXT | The dbt log directory used for the run, relative to the dbt project root, such as logs. Reflects the --log-path flag or a log path environment variable, such as DBT_LOG_PATH, if set; otherwise, the dbt default. NULL if the path wasn’t recorded for the run. LAST_DEPLOYED_FROM | VARIANT | An OBJECT that describes the source of the most recent deployment, if the deployment included Git information. It contains stage_url when the project was deployed from a Git repository stage without a Git URL, or git_url when a Git URL was specified. It also contains git_commit, git_branch, user, and timestamp fields. The value is recorded when the run starts, so later deployments of the project don’t change it. NULL for workspace runs and for deployments without Git information, such as deployments from a stage that isn’t a Git repository stage. This value comes from the last_deployed_from column returned by SHOW DBT PROJECTS, which has examples of each case.
Access control requirements
This table function includes only runs from workspaces and dbt Projects in which you have the following privileges: - OWNERSHIP, READ, or WRITE on workspaces - OWNERSHIP, USAGE, or MONITOR on dbt Projects