数据分类系统表参考

重要

此功能目前以公共预览版提供。

本页概述了数据分类结果表架构,并包括示例查询。 该表将敏感数据类的检测存储在元存储中已启用的目录的列级别。

表路径system.data_classification.results

数据分类结果表架构

数据分类结果系统表使用以下架构:

列名称 数据类型 Description Example
latest_detected_time 时间戳 最近扫描该列的时间点。 2025-06-27T12:34
first_detected_time 时间戳 首次记录列检测的时间。 2025-06-27T12:34
catalog_id 字符串 目录 ID。 3f1a7d6e-9c59-...
table_id 字符串 表的 ID。 3f1a7d6e-9c59-...
catalog_name 字符串 目录名称。 main_catalog
schema_name 字符串 架构名称。 public
table_name 字符串 表名。 sales_data
column_name 字符串 列名。 customer_email
data_type 字符串 列的数据类型。 复杂类型包括完整的结构定义。 struct<name:string, age:int>
class_tag 字符串 检测到的实体或标签键以及可选值的标签。 class.us_ssnpii: confidential
samples array<string> 最多五个与检测匹配的示例值。 ["a@b.com", ...]
confidence 字符串 检测的置信度。 HIGHLOW HIGH
frequency float 估计示例中匹配行的比例。 介于 0 和 1 之间。 0.87

示例查询

在运行之前,请将参数值替换为自己的值。

获取表的所有检测

SELECT *
FROM system.data_classification.results
WHERE
  catalog_name = "c"
  AND schema_name = "s"
  AND table_name = "t";

获取所有高置信度识别结果

SELECT *
FROM system.data_classification.results
WHERE
  catalog_name = "c"
  AND schema_name = "s"
  AND table_name = "t"
  AND confidence = "HIGH";

获取受特定分类影响的表数

SELECT
  class_tag,
  COUNT(DISTINCT catalog_name, schema_name, table_name) AS num_tables
FROM
  system.data_classification.results
WHERE
  class_tag IS NOT NULL
GROUP BY class_tag;

获取过去 30 天内查询包含敏感数据的表的用户数

WITH table_accesses AS (
  SELECT
    IFNULL(
      request_params.full_name_arg,
      CONCAT(request_params.catalog_name, '.', request_params.schema_name, '.', request_params.name)
    ) AS table_full_name,
    COUNT(DISTINCT user_identity.email) AS num_users
  FROM
    system.access.audit
  WHERE
    action_name IN ("createTable", "getTable", "updateTable", "deleteTable")
    AND (
      -- For performance, limit the blast radius of the audit log query to only the current catalog
      request_params.catalog_name = :catalog_name OR
      request_params.full_name_arg LIKE :catalog_name || '%'
    )
    AND event_time >= DATE_SUB(current_date(), 30)
  GROUP BY table_full_name
),
sensitive_tables AS (
  SELECT
    DISTINCT CONCAT(catalog_name, '.', schema_name, '.', table_name) AS table_full_name
  FROM
    system.data_classification.results
  WHERE class_tag IS NOT NULL
)

SELECT
  st.table_full_name,
  ta.num_users
FROM
  sensitive_tables st
  JOIN table_accesses ta
  ON st.table_full_name = ta.table_full_name