This action retrieves the result of a previously executed SQL statement in Databricks.

Prerequisites

  • The result set returned by this action originates from a SQL statement executed against Unity Catalog (UC)-registered assets. The same UC namespace and permission requirements from Execute SQL statement apply.
  • The authenticating identity (user or service principal) must hold the minimum UC privileges required to read the target tables. The below table lists the required minimum privileges.
    Object Minimum privilege Databricks navigation
    Catalog USE CATALOG Refer Execute SQL statement prerequisites (Databricks navigation)
    Schema USE SCHEMA
    Table (read) SELECT
    Table (write/modify) SELECT, MODIFY
    Note: The SELECT and MODIFY privileges can be granted at the catalog or schema level to apply to all current and future objects within them, reducing per-table grant overhead for automations that operate across multiple tables.

    For more details about privileges, see Databricks privileges.

Settings

  • Use the Session field to select one of the following options:
    • Session name: Enter the name of the session used during Connect action.

      Click the Insert a value icon to select an existing variable that you have used to store the default session name.

    • Variable: Enter the name of the variable that you have used to store the session name.
  • Enter the unique statement ID returned from the Execute SQL statement action.
  • In the Rows limit field, specify the maximum number of rows that you want to return from the query.
  • Enter a query timeout value.

    When the specified time expires, the statement execution stops even if the execution is not completed.

  • In the Assign output to a variable field, select a datatable variable to iterate over rows and store the retrieved result set. If the variable is not available in the list, click Create variable.

    Returns the SQL query result, the output typically includes rows returned by the SQL query.