

 Amazon Redshift는 패치 198부터 새 Python UDF 생성을 더 이상 지원하지 않습니다. 기존 Python UDF는 2026년 6월 30일까지 계속 작동합니다. 자세한 내용은 [블로그 게시물](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)을 참조하세요.

# SYS\$1UDF\$1LOG
<a name="SYS_UDF_LOG"></a>

사용자 정의 함수(UDF)를 실행하는 중에 생성되는 시스템 정의 오류 및 경고 메시지를 기록합니다.

SYS\$1UDF\$1LOG는 수퍼유저에게만 표시됩니다. 자세한 내용은 [시스템 테이블 및 뷰에 있는 데이터의 가시성](cm_chap_system-tables.md#c_visibility-of-data) 섹션을 참조하세요.

## 테이블 열
<a name="SYS_UDF_LOG-table-rows"></a>

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/redshift/latest/dg/SYS_UDF_LOG.html)

## 샘플 쿼리
<a name="SYS_UDF_LOG-sample-queries"></a>

다음 예는 UDF가 시스템 정의 오류를 처리하는 방법을 보여 줍니다. 첫 번째 블록은 인수의 역을 반환하는 UDF 함수의 정의를 보여 줍니다. 함수를 실행하고 인수로 0을 제공하면 함수가 오류를 반환합니다. 마지막 문은 SYS\$1UDF\$1LOG에 로깅된 오류 메시지를 반환합니다.

```
-- 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 0 to create an error.
Select f_udf_inv(0); 

-- Query SYS_UDF_LOG to view the message.
Select query_id, record_time, message::varchar from sys_udf_log; 


query_id    |    record_time              |                 message
----------+----------------------------+-------------------------------------------------------
2211        | 2023-08-23 15:53:11.360538 |  ZeroDivisionError: integer division or modulo by zero line 2, in f_udf_inv\n return 1/a\n
```

다음 예는 UDF에 로깅 및 경고 메시지를 추가하므로 0으로 나누기 연산은 오류 메시지와 함께 중단되는 대신 경고 메시지를 생성합니다.

```
-- Create a function to find the inverse of a number and log a warning if you input 0.
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;

-- Run the function with 0 to trigger the warning.
Select f_udf_inv_log(0);

-- Query SYS_UDF_LOG to view the message.
Select query_id, record_time, message::varchar from sys_udf_log;

 query_id |        record_time         |                                    message
----------+----------------------------+-------------------------------------------------------------------------------
     0   | 2023-08-23 16:10:48.833503 | WARNING: You attempted to divide by zero.\nReturning zero instead of error.\n
```