

 Amazon Redshift will no longer support the creation of new Python UDFs starting Patch 198. Existing Python UDFs will continue to function until June 30, 2026. For more information, 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/). 

# SVL\_UDF\_LOG
<a name="r_SVL_UDF_LOG"></a>

 Records system-defined error and warning messages generating during user-defined function (UDF) execution. 

SVL\_UDF\_LOG is visible to all users. Superusers can see all rows; regular users can see only their own data. For more information, see [Visibility of data in system tables and views](cm_chap_system-tables.md#c_visibility-of-data). 

Some or all of the data in this table can also be found in the SYS monitoring view [SYS\_UDF\_LOG](SYS_UDF_LOG.md). The data in the SYS monitoring view is formatted to be easier to use and understand. We recommend that you use the SYS monitoring view for your queries.

## Table columns
<a name="SVL_UDF_LOG-table-columns"></a>


| Column name  | Data type  | Description  | 
| --- | --- | --- | 
| query | bigint | The query ID. You can use this ID to join various other system tables and views. | 
| message | char(4096) | The message generated by the function. | 
| created | timestamp | The time that the log was created. | 
| traceback | char(4096) | If available, this value provides a stack traceback for the UDF. For more information, see [traceback](https://docs.python.org/2/library/traceback.html) in the Python Standard Library.  | 
| funcname  | character(256) | The name of the UDF that is executing. | 
| node  | integer | The node where the message was generated. | 
| slice | integer | The slice where the message was generated. | 
| seq | integer | The sequence of the message on the slice. | 

## Sample queries
<a name="SVL_UDF_LOG-sample-queries"></a>

The following example shows how UDFs handle system-defined errors. The first block shows the definition for a UDF function that returns the inverse of an argument. When you run the function and provide a 0 argument, as the second block shows, the function returns an error. The third statement reads the error message that is logged in SVL\_UDF\_LOG

```
-- Create a function to find the inverse of a number

CREATE OR REPLACE FUNCTION  f_udf_inv(a int)
  RETURNS float IMMUTABLE
AS $$
   return 1/a
$$ LANGUAGE plpythonu;

-- Run the function with a 0 argument to create an error
Select f_udf_inv(0) from sales;

-- Query SVL_UDF_LOG to view the message

Select query, created, message::varchar
from svl_udf_log;

 query |          created           | message                             
-------+----------------------------+---------------------------------------------------------
  2211 | 2015-08-22 00:11:12.04819  | ZeroDivisionError: long division or modulo by zero\nNone
```

The following example adds logging and a warning message to the UDF so that a divide by zero operation results in a warning message instead of stopping with an error message. 

```
-- Create a function to find the inverse of a number and log a warning

CREATE OR REPLACE FUNCTION f_udf_inv_log(a int)
  RETURNS float IMMUTABLE
 AS $$ 
  import logging
  logger = logging.getLogger() #get root logger
  if a==0:
    logger.warning('You attempted to divide by zero.\nReturning zero instead of error.\n') 
    return 0
  else:
     return 1/a
$$ LANGUAGE plpythonu;
```

The following example runs the function, then queries SVL\_UDF\_LOG to view the message.

```
-- Run the function with a 0 argument to trigger the warning
Select f_udf_inv_log(0) from sales;

-- Query SVL_UDF_LOG to view the message

Select query, created, message::varchar
from svl_udf_log;

query |          created           | message                             
------+----------------------------+----------------------------------
    0 | 2015-08-22 00:11:12.04819  | You attempted to divide by zero. 
                                     Returning zero instead of error.
```