

 Amazon Redshift will no longer support the use of Python UDFs after June 30, 2026. We will start enforcing it in phases. For more information on the details of Python end of life and migration options, see the [ blog post ](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/) that was published on June 30, 2025. 

# PG\_LAST\_UNLOAD\_ID
<a name="PG_LAST_UNLOAD_ID"></a>

Returns the query ID of the most recently completed UNLOAD command in the current session. If no UNLOAD commands have been run in the current session, PG\_LAST\_UNLOAD\_ID returns -1. 

 The value for PG\_LAST\_UNLOAD\_ID is updated when the UNLOAD command begins the load process. If the UNLOAD fails because of invalid load data, the UNLOAD ID is updated, so you can use the UNLOAD ID for further investigation. If the UNLOAD transaction is rolled back, the UNLOAD ID is not updated. 

The UNLOAD ID is not updated if the UNLOAD command fails because of an error that occurs before the load process begins, such as a syntax error, access error, invalid credentials, or insufficient privileges. 

## Syntax
<a name="PG_LAST_UNLOAD_ID-synopsis"></a>

```
PG_LAST_UNLOAD_ID()
```

## Return type
<a name="PG_LAST_UNLOAD_ID-return-type"></a>

Returns an integer.

## Example
<a name="PG_LAST_UNLOAD_ID-example"></a>

The following query returns the query ID of the latest UNLOAD command in the current session.

```
select PG_LAST_UNLOAD_ID();

PG_LAST_UNLOAD_ID
---------------
          5437
(1 row)
```