

 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/)을 참조하세요.

# SVL\$1UDF\$1LOG
<a name="r_SVL_UDF_LOG"></a>

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

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

이 테이블의 데이터 중 일부 또는 전부는 SYS 모니터링 뷰인 [SYS\$1UDF\$1LOG](SYS_UDF_LOG.md)에서도 찾아볼 수 있습니다. SYS 모니터링 뷰의 데이터는 사용 및 이해가 더 쉽도록 형식이 지정되어 있습니다. 쿼리에 SYS 모니터링 뷰를 사용하는 것이 좋습니다.

## 테이블 열
<a name="SVL_UDF_LOG-table-columns"></a>

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

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

다음 예는 UDF가 시스템 정의 오류를 처리하는 방법을 보여 줍니다. 첫 번째 블록은 인수의 역을 반환하는 UDF 함수의 정의를 보여 줍니다. 두 번째 블록에서처럼 함수를 실행하고 0개의 인수를 제공하면 함수가 오류를 반환합니다. 세 번째 문은 SVL\$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 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
```

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

```
-- 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;
```

다음 예제는 함수를 실행한 다음 SVL\$1UDF\$1LOG를 쿼리하여 메시지를 조회합니다.

```
-- 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.
```