event_log 테이블 반환 함수

적용 대상:검사 '예'로 표시 Databricks SQL 검사 '예'로 표시 Databricks Runtime 13.3 LTS 이상

구체화된 뷰, 스트리밍 테이블DLT 파이프라인에 대한 이벤트 로그를 반환합니다.

Delta Live Tables 이벤트 로그에 대해 자세히 알아봅니다.

구문

event_log( { TABLE ( table_name ) | pipeline_id } )

인수

  • table_name: 구체화된 뷰 또는 스트리밍 테이블의 이름입니다. 이름에는 임시 사양이 포함되지 않아야 합니다. 이름이 정규화되지 않은 경우 현재 카탈로그와 스키마를 사용하여 식별자를 한정합니다.
  • pipeline_id: Delta Live Tables 파이프라인의 문자열 식별자입니다.

반품

  • 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, , WARNERROR또는 METRICS.
  • maturity_level STRING NOT NULL: 이벤트 스키마의 안정성입니다. 가능한 값은 다음과 같습니다.
    • STABLE: 스키마가 안정적이며 변경되지 않습니다.
    • NULL: 스키마가 안정적이며 변경되지 않습니다. 값은 필드가 추가되기 NULL 전에 레코드를 maturity_level 만든 경우일 수 있습니다(릴리스 2022.37).
    • EVOLVING: 스키마가 안정적이지 않고 변경 될 수 있습니다.
    • DEPRECATED: 스키마는 더 이상 사용되지 않으며 Delta Live Tables 런타임은 언제든지 이 이벤트 생성을 중지할 수 있습니다.
  • error STRING: 오류가 발생한 경우 오류를 설명하는 세부 정보입니다.
  • details STRING NOT NULL: 이벤트의 구조적 세부 정보를 포함하는 JSON 개체입니다. 이벤트를 분석하는 데 사용되는 기본 필드입니다.
  • event_type STRING NOT NULL: 이벤트 유형입니다.

사용

파이프라인, 스트리밍 테이블 또는 구체화된 뷰의 소유자만 이벤트 로그를 볼 수 있습니다. 보기를 만들고 다른 사용자가 이벤트 로그를 쿼리할 수 있도록 보기에 대한 액세스 권한을 사용자에게 부여합니다.

> CREATE VIEW event_log_raw AS SELECT * FROM event_log(table(my_mv));
> GRANT SELECT ON VIEW event_log_raw TO `user@databricks.com`;

예제

자세한 예제는 이벤트 로그 쿼리를 참조 하세요.

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