카테고리:

시스템 함수 (시스템 정보)

GET_PYTHON_PROFILER_OUTPUT (SNOWFLAKE.CORE)

Python 코드 프로파일러 에서 생성한 보고서가 포함된 출력을 반환합니다.

구문

SNOWFLAKE.CORE.GET_PYTHON_PROFILER_OUTPUT(<query_id>)
Copy

인자

query_id

프로파일링이 활성화된 저장 프로시저 쿼리의 ID 를 쿼리합니다.

반환

코드 프로파일러 에서 생성된 보고서가 포함된 VARCHAR 유형의 문자열입니다.

액세스 제어 요구 사항

이 함수를 호출하려면 ACCOUNTADMIN 역할을 사용해야 합니다.

프로파일러가 시간이 아닌 프로필 메모리로 설정된 경우 설정은 다음과 같이 표시됩니다.

Handler Name: main
Python Runtime Version: 3.8
Modules Profiled: ['main_module']
File: _udf_code.py
Function: main at line 4

Line #   Mem usage    Increment  Occurrences  Line Contents
=============================================================
    4    245.3 MiB    245.3 MiB           1   def main(session, last_n, total):
    5                                             # create sample dataset to emulate id + elapsed time
    6    245.8 MiB      0.5 MiB           1       session.sql('''
    7                                                 CREATE OR REPLACE TABLE sample_query_history (query_id INT, elapsed_time FLOAT)''').collect()
    8    245.8 MiB      0.0 MiB           2       session.sql('''
    9                                             INSERT INTO sample_query_history
    10                                             SELECT
    11                                             seq8() AS query_id,
    12                                             uniform(0::float, 100::float, random()) as elapsed_time
    13    245.8 MiB      0.0 MiB           1       FROM table(generator(rowCount => {0}));'''.format(total)).collect()
    14
    15                                             # get the mean of the last n query elapsed time
    16    245.8 MiB      0.0 MiB           3       df = session.table('sample_query_history').select(
    17    245.8 MiB      0.0 MiB           1           funcs.col('query_id'),
    18    245.8 MiB      0.0 MiB           2           funcs.col('elapsed_time')).limit(last_n)
    19
    20    327.9 MiB     82.1 MiB           1       pandas_df = df.to_pandas()
    21    328.9 MiB      1.0 MiB           1       mean_time = pandas_df.loc[:, 'ELAPSED_TIME'].mean()
    22    320.9 MiB     -8.0 MiB           1       del pandas_df
    23    320.9 MiB      0.0 MiB           1       return mean_time