테이블 값 함수
적용 대상: Databricks SQL
Databricks Runtime 13.3 LTS 이상
구체화된 뷰, 스트리밍 테이블 및 Lakeflow 선언적 파이프라인에 대한 이벤트 로그를 반환합니다.
Lakeflow 선언적 파이프라인 이벤트 로그에 대해 자세히 알아봅니다.
참고
이 함수는 레거시 게시 모드를 사용하여 게시된 Unity 카탈로그 파이프라인에만 적용됩니다. 다른 모든 파이프라인의 경우 이벤트 로그 테이블을 직접 쿼리합니다.
event_log
테이블 반환 함수는 스트리밍 테이블 또는 구체화된 뷰의 소유자만 호출할 수 있으며, event_log
테이블 반환 함수를 통해 만든 뷰는 스트리밍 테이블 또는 구체화된 뷰의 소유자만 쿼리할 수 있습니다. 해당 보기는 다른 사용자와 공유할 수 없습니다.
구문
event_log( { TABLE ( table_name ) | pipeline_id } )
논쟁
- table_name: 구체화된 뷰 또는 스트리밍 테이블의 이름입니다. 이름에는 임시 사양이 포함되지 않아야 합니다. 이름이 정규화되지 않은 경우 현재 카탈로그와 스키마를 사용하여 식별자를 한정합니다.
-
pipeline_id
: 파이프라인의 문자열 식별자입니다.
반품
-
id STRING NOT NULL
: 이벤트 로그 레코드의 고유 식별자입니다. -
sequence STRING NOT NULL
: 이벤트를 식별하고 정렬하는 메타데이터를 포함하는 JSON 개체입니다. -
origin STRING NOT NULL
: 이벤트 원본에 대한 메타데이터(예: 클라우드 공급자, 지역user_id
또는pipeline_id
)를 포함하는 JSON 개체입니다. -
timestamp TIMESTAMP NOT NULL
: 이벤트가 UTC로 기록된 시간입니다. -
message STRING NOT NULL
: 이벤트를 설명하는 사람이 읽을 수 있는 메시지입니다. -
level STRING NOT NULL
: 로깅 수준(예:INFO
, ,WARN
ERROR
또는METRICS
. -
maturity_level STRING NOT NULL
: 이벤트 스키마의 안정성입니다. 가능한 값은 다음과 같습니다.-
STABLE
: 스키마가 안정적이며 변경되지 않습니다. -
NULL
: 스키마가 안정적이며 변경되지 않습니다. 해당 값은NULL
필드가 추가되기 전(릴리스 2022.37) 레코드가 생성된 경우maturity_level
일 수 있습니다. -
EVOLVING
: 스키마가 안정적이지 않아 변경 될 수 있습니다. -
DEPRECATED
: 스키마는 더 이상 사용되지 않으며 Lakeflow 선언적 파이프라인 런타임은 언제든지 이 이벤트 생성을 중지할 수 있습니다.
-
-
error STRING
: 오류가 발생한 경우 오류를 설명하는 세부 정보입니다. -
details STRING NOT NULL
: 이벤트의 구조적 세부 정보를 포함하는 JSON 개체입니다. 이벤트를 분석하는 데 사용되는 기본 필드입니다. -
event_type STRING NOT NULL
: 이벤트 유형입니다.
예제
자세한 예제는 이벤트 로그쿼리를 참조하세요.
-- View the events on a materialized view
> SELECT timestamp, message, details
FROM event_log(table(my_mv))
WHERE level in ('INFO', 'WARN', 'ERROR')
ORDER BY timestamp;
timestamp, message, details
---------------------------
2023-08-12 01:03:05.000, 'Flow "my_mv" is STARTING.', '{"flow_progress":{"status":"STARTING"}}'
-- Create a temp view with the latest update to the table/pipeline
> CREATE OR REPLACE TEMP VIEW latest_update AS
SELECT origin.update_id AS id FROM event_log('<pipeline-ID>')
WHERE event_type = 'create_update' ORDER BY timestamp DESC LIMIT 1;
-- Query lineage information
> SELECT
details:flow_definition.output_dataset as output_dataset,
details:flow_definition.input_datasets as input_dataset
FROM
event_log('<pipeline-ID>'),
latest_update
WHERE
event_type = 'flow_definition' AND origin.update_id = latest_update.id;
output_dataset, input_dataset
-----------------------------
customers, null
sales_orders_raw, null
sales_orders_cleaned, ["customers", "sales_orders_raw"]
sales_order_in_la, ["sales_orders_cleaned"]
-- Query data quality expectation history for a streaming table
> WITH expectations_parsed AS (
SELECT
explode(
from_json(
details:flow_progress.data_quality.expectations,
"array<struct<name: string, dataset: string, passed_records: int, failed_records: int>>"
)
) row_expectations
FROM
event_log(table(my_st)),
latest_update
WHERE
event_type = 'flow_progress'
AND origin.update_id = latest_update.id
)
SELECT
row_expectations.dataset as dataset,
row_expectations.name as expectation,
SUM(row_expectations.passed_records) as passing_records,
SUM(row_expectations.failed_records) as failing_records
FROM expectations_parsed
GROUP BY
row_expectations.dataset,
row_expectations.name;
dataset, expectation, passing_records, failing_records
------------------------------------------------------
sales_orders_cleaned, valid_order_number, 4083, 0