保险核心业务数仓(合规报表)最佳实践

将承保核心系统的保单、理赔和客户数据整合为多层数仓,满足银保监会(CBIRC)合规报表要求。本文以 Kaggle Insurance Claims 数据集(100 条车险保单)为基础,端到端演示 ODS → DWD → DWS → ADS 的完整构建过程,覆盖 Oracle/PostgreSQL 批量同步、Dynamic Table 定期刷新、Time Travel 历史核对、Column Masking 数据脱敏、RBAC 细粒度授权五项关键平台能力。


概述

保险核心业务数仓面临以下典型问题:

问题解决方案
核心系统(Oracle/PG)每日 T+1 全量同步到数仓批量离线同步任务,ODS 层保留原始字段结构
DWS/ADS 层每日刷新,计算产品盈利和地区风险Dynamic Table,不写 REFRESH INTERVAL,通过 Studio Task 调度
月末对账与监管历史回溯,需精确还原任意时间点数据Time Travel,
TIMESTAMP AS OF
TIMESTAMP AS OF
查询历史快照
投保人身份证号、银行卡号、医疗信息等敏感字段需脱敏Column Masking,绑定到列,对非特权用户透明
精算部、理赔部、合规部、IT 运维权限分级管理RBAC,细粒度角色授权,最小权限原则

涉及的 SQL 命令

命令 / 函数用途说明
CREATE TABLE
CREATE TABLE
建 ODS 层原始保单表普通表,作为 Dynamic Table 上游
CREATE BLOOMFILTER INDEX
CREATE BLOOMFILTER INDEX
policy_id
policy_id
列创建 Bloomfilter 索引
高基数保单号点查加速
CREATE OR REPLACE FUNCTION
CREATE OR REPLACE FUNCTION
创建客户年龄脱敏函数非授权用户只能看到年龄段
ALTER TABLE ... CHANGE COLUMN ... SET MASK
ALTER TABLE ... CHANGE COLUMN ... SET MASK
绑定 Column Masking 策略
customer_age
customer_age
脱敏
CREATE DYNAMIC TABLE
CREATE DYNAMIC TABLE
创建 DWD/DWS/ADS 层增量计算表不含 REFRESH INTERVAL,用 Studio Task 调度
REFRESH DYNAMIC TABLE
REFRESH DYNAMIC TABLE
手动触发首次刷新初次构建或调试时使用
DESC HISTORY
DESC HISTORY
查看表版本历史获取月末快照时间点
SELECT ... TIMESTAMP AS OF
SELECT ... TIMESTAMP AS OF
Time Travel 历史查询精确还原任意时间点数据状态

前置准备

本文所有示例在

best_practice_insurance_dw
best_practice_insurance_dw
Schema 下运行。

CREATE SCHEMA IF NOT EXISTS best_practice_insurance_dw;


ODS 层:原始保单表

建表

ODS 层完整保留来源系统字段,不做任何转换,便于数据溯源和监管审计。

CREATE TABLE IF NOT EXISTS best_practice_insurance_dw.doc_ods_insurance_policy ( policy_id STRING, -- 保单号(主键,高基数) subscription_length DOUBLE, -- 保单年限(年) vehicle_age DOUBLE, -- 车龄(年) customer_age INT, -- 客户年龄(敏感字段,需脱敏) region_code STRING, -- 地区代码 region_density INT, -- 地区人口密度 segment STRING, -- 险种段(A/B1/B2/C1/C2/Utility) model STRING, -- 车型 fuel_type STRING, -- 燃料类型(Petrol/CNG/Diesel) max_torque STRING, max_power STRING, engine_type STRING, airbags INT, is_esc STRING, is_adjustable_steering STRING, is_tpms STRING, is_parking_sensors STRING, is_parking_camera STRING, rear_brakes_type STRING, displacement INT, cylinder INT, transmission_type STRING, steering_type STRING, turning_radius DOUBLE, length INT, width INT, gross_weight INT, is_front_fog_lights STRING, is_rear_window_wiper STRING, is_rear_window_washer STRING, is_rear_window_defogger STRING, is_brake_assist STRING, is_power_door_locks STRING, is_central_locking STRING, is_power_steering STRING, is_driver_seat_height_adjustable STRING, is_day_night_rear_view_mirror STRING, is_ecw STRING, is_speed_alert STRING, ncap_rating INT, -- NCAP 安全评级(0-5) claim_status INT -- 理赔状态(0=未理赔, 1=已理赔) );

从本地 CSV 导入数据(推荐):

-- 第一步:通过 SQL PUT 将本地 CSV 文件上传到 User Volume PUT '/path/to/your/data.csv' TO USER VOLUME FILE 'data.csv';

-- 第二步:从 User Volume COPY INTO 表 COPY INTO best_practice_insurance_dw.doc_ods_insurance_policy FROM USER VOLUME USING csv OPTIONS('header'='true', 'sep'=',', 'nullValue'='') FILES ('data.csv');

也可直接内联插入小批量测试数据(不需要 CSV 文件):

写入后验证行数:

SELECT COUNT(*) AS ods_row_count FROM best_practice_insurance_dw.doc_ods_insurance_policy;

ods_row_count ------------- 100

创建 Bloomfilter Index

policy_id
policy_id
是核心业务主键,高基数列,后续 DWD/DWS/ADS 层都会通过保单号做关联查询,适合 Bloomfilter Index。

CREATE BLOOMFILTER INDEX IF NOT EXISTS idx_bf_policy_id ON TABLE doc_ods_insurance_policy (policy_id);

Column Masking:客户年龄脱敏

合规要求:

customer_age
customer_age
属于个人敏感信息,精算部和合规管理员可查看精确年龄,其他用户只能查看"年龄段"(精度降至 10 的倍数)。

-- 创建脱敏函数 CREATE OR REPLACE FUNCTION best_practice_insurance_dw.mask_customer_age(age INT) RETURNS INT AS CASE WHEN current_user() IN ('privileged_user') THEN age -- 替换为实际获授权的用户名 ELSE CAST(FLOOR(CAST(age AS DOUBLE) / 10.0) * 10 AS INT) END; -- 绑定到 customer_age 列 ALTER TABLE best_practice_insurance_dw.doc_ods_insurance_policy CHANGE COLUMN customer_age SET MASK best_practice_insurance_dw.mask_customer_age;

验证绑定效果(管理员账号看原始精确年龄):

SELECT policy_id, customer_age FROM best_practice_insurance_dw.doc_ods_insurance_policy WHERE policy_id IN ('POL007194', 'POL016745', 'POL045360') ORDER BY policy_id;

policy_id | customer_age -----------+------------- POL007194 | 44 POL016745 | 35 POL045360 | 41


DWD 层:保单生命周期标准化

DWD 层在 ODS 原始保单基础上做三件事:

  1. 增加客户年龄分段(
    age_group
    age_group
    )、车龄分段(
    vehicle_age_group
    vehicle_age_group
    )、保单年限分段(
    policy_tenure_group
    policy_tenure_group
  2. 打高风险标记(
    is_high_risk
    is_high_risk
    ):车龄 ≥ 5 年或 NCAP 安全评分为 0
  3. 保留全部原始字段,供 DWS/ADS 层任意维度聚合

建表

CREATE DYNAMIC TABLE IF NOT EXISTS best_practice_insurance_dw.doc_dwd_policy_lifecycle AS SELECT policy_id, subscription_length, vehicle_age, customer_age, region_code, region_density, segment, model, fuel_type, engine_type, airbags, displacement, cylinder, transmission_type, ncap_rating, claim_status, -- 客户年龄分段 CASE WHEN customer_age < 30 THEN 'Young (<30)' WHEN customer_age < 45 THEN 'Middle (30-44)' WHEN customer_age < 60 THEN 'Senior (45-59)' ELSE 'Elderly (60+)' END AS age_group, -- 车龄分段 CASE WHEN vehicle_age < 1 THEN 'New (<1yr)' WHEN vehicle_age < 3 THEN 'Recent (1-3yr)' WHEN vehicle_age < 5 THEN 'Mid (3-5yr)' ELSE 'Old (5+yr)' END AS vehicle_age_group, -- 保单年限分段 CASE WHEN subscription_length < 3 THEN 'Short (<3yr)' WHEN subscription_length < 7 THEN 'Medium (3-7yr)' ELSE 'Long (7+yr)' END AS policy_tenure_group, -- 高风险标记:车龄超5年 或 NCAP评分为0 CASE WHEN vehicle_age >= 5 OR ncap_rating = 0 THEN 1 ELSE 0 END AS is_high_risk FROM best_practice_insurance_dw.doc_ods_insurance_policy;

手动触发首次刷新:

REFRESH DYNAMIC TABLE best_practice_insurance_dw.doc_dwd_policy_lifecycle; SELECT COUNT(*) AS dwd_count FROM best_practice_insurance_dw.doc_dwd_policy_lifecycle;

dwd_count --------- 100

分析示例:年龄段与车龄段交叉理赔率

SELECT age_group, vehicle_age_group, COUNT(*) AS policy_count, SUM(claim_status) AS claim_count FROM best_practice_insurance_dw.doc_dwd_policy_lifecycle GROUP BY age_group, vehicle_age_group ORDER BY claim_count DESC;

age_group | vehicle_age_group | policy_count | claim_count --------------------+-------------------+--------------+------------ Middle (30-44) | Recent (1-3yr) | 37 | 2 Middle (30-44) | New (<1yr) | 19 | 1 Senior (45-59) | New (<1yr) | 18 | 1 Senior (45-59) | Recent (1-3yr) | 15 | 1 Senior (45-59) | Mid (3-5yr) | 4 | 0 Senior (45-59) | Old (5+yr) | 1 | 0 Middle (30-44) | Mid (3-5yr) | 4 | 0 Elderly (60+) | New (<1yr) | 2 | 0

结果解读:30–44 岁中年客户群是保单量最大的客群(60 条),也贡献了最多理赔(3 件)。值得注意的是,"车龄 1–3 年"段理赔件数高于"车龄 5 年以上",说明新近购车者风险敞口较高,可能与新手行驶习惯有关。


DWS 层:产品类型/地区聚合

DWS 层以

segment × fuel_type × region_code × age_group
segment × fuel_type × region_code × age_group
为粒度聚合 DWD 数据,输出理赔率、高风险率等指标,供 ADS 层合规报表直接引用。

建表

CREATE DYNAMIC TABLE IF NOT EXISTS best_practice_insurance_dw.doc_dws_product_region_daily AS SELECT segment, fuel_type, region_code, age_group, COUNT(*) AS policy_count, SUM(claim_status) AS claim_count, ROUND(SUM(claim_status) * 100.0 / COUNT(*), 4) AS claim_rate_pct, ROUND(AVG(vehicle_age), 2) AS avg_vehicle_age, ROUND(AVG(customer_age), 2) AS avg_customer_age, ROUND(AVG(subscription_length), 2) AS avg_subscription_length, SUM(is_high_risk) AS high_risk_count, ROUND(SUM(is_high_risk) * 100.0 / COUNT(*), 4) AS high_risk_rate_pct FROM best_practice_insurance_dw.doc_dwd_policy_lifecycle GROUP BY segment, fuel_type, region_code, age_group;

手动触发首次刷新并验证:

REFRESH DYNAMIC TABLE best_practice_insurance_dw.doc_dws_product_region_daily; SELECT COUNT(*) AS dws_count FROM best_practice_insurance_dw.doc_dws_product_region_daily;

dws_count --------- 59

查看有理赔记录的险种-地区组合:

SELECT segment, fuel_type, region_code, policy_count, claim_count, claim_rate_pct, high_risk_count FROM best_practice_insurance_dw.doc_dws_product_region_daily WHERE claim_count > 0 ORDER BY claim_rate_pct DESC;

segment | fuel_type | region_code | policy_count | claim_count | claim_rate_pct | high_risk_count --------+-----------+-------------+--------------+-------------+----------------+---------------- B2 | Petrol | C10 | 1 | 1 | 100.0000 | 0 C1 | Diesel | C2 | 2 | 1 | 50.0000 | 0 B1 | CNG | C5 | 2 | 1 | 50.0000 | 0 C2 | Diesel | C2 | 4 | 1 | 25.0000 | 0 A | CNG | C3 | 5 | 1 | 20.0000 | 5

结果解读:C10 地区 B2 险种(Petrol)理赔率 100% 但仅 1 张保单,属于小样本噪声;C2 地区 C1 和 C2 险种(Diesel)理赔率高(50% 和 25%),且覆盖多张保单,值得重点关注;C3 地区 A 段(CNG)5 件保单全部被标记为高风险(

ncap_rating = 0
ncap_rating = 0
),提示该地区低端车型安全配置不足。


ADS 层:银保监合规报表

产品类型盈利分析报表

按险种和燃料类型聚合,输出理赔率、地区覆盖、高风险保单数,满足 CBIRC 产品经营分析报告要求。

CREATE DYNAMIC TABLE IF NOT EXISTS best_practice_insurance_dw.doc_ads_regulatory_report AS SELECT segment AS product_type, fuel_type, COUNT(*) AS total_policies, SUM(claim_status) AS total_claims, ROUND(SUM(claim_status) * 100.0 / COUNT(*), 4) AS claim_rate_pct, COUNT(DISTINCT region_code) AS covered_regions, SUM(is_high_risk) AS high_risk_policies, ROUND(SUM(is_high_risk) * 100.0 / COUNT(*), 4) AS high_risk_rate_pct, ROUND(AVG(customer_age), 2) AS avg_customer_age, ROUND(AVG(vehicle_age), 2) AS avg_vehicle_age, ROUND(AVG(subscription_length), 2) AS avg_policy_tenure, ROUND(AVG(ncap_rating), 2) AS avg_safety_rating FROM best_practice_insurance_dw.doc_dwd_policy_lifecycle GROUP BY segment, fuel_type;

REFRESH DYNAMIC TABLE best_practice_insurance_dw.doc_ads_regulatory_report; SELECT product_type, fuel_type, total_policies, total_claims, claim_rate_pct, covered_regions, high_risk_policies, avg_safety_rating FROM best_practice_insurance_dw.doc_ads_regulatory_report ORDER BY total_policies DESC;

product_type | fuel_type | total_policies | total_claims | claim_rate_pct | covered_regions | high_risk_policies | avg_safety_rating -------------+-----------+----------------+--------------+----------------+-----------------+--------------------+------------------ B2 | Petrol | 31 | 1 | 3.2258 | 11 | 8 | 1.55 A | CNG | 27 | 1 | 3.7037 | 12 | 27 | 0 C2 | Diesel | 20 | 1 | 5.0000 | 7 | 0 | 3 B1 | CNG | 6 | 1 | 16.6667 | 5 | 0 | 2 C1 | Diesel | 5 | 1 | 20.0000 | 4 | 0 | 4 C1 | Petrol | 3 | 0 | 0.0000 | 2 | 0 | 2 Utility | CNG | 3 | 0 | 0.0000 | 3 | 3 | 0 A | Petrol | 3 | 0 | 0.0000 | 3 | 0 | 2 B2 | Diesel | 2 | 0 | 0.0000 | 2 | 0 | 5

结果解读

  • A(基础型)CNG 是最大险种(27 张),但 100% 被标记为高风险(
    ncap_rating = 0
    ncap_rating = 0
    ),说明该产品类型覆盖了大量安全配置不足的廉价车型,合规部门需关注。
  • C1 Diesel 理赔率最高(20%),NCAP 均分 4 分,说明高端安全配置并不能显著降低 C1 级别的事故概率。
  • B2 Petrol 保单量最大,理赔率仅 3.2%,覆盖 11 个地区,是盈利能力最好的产品线。

地区风险集中度报表

CREATE DYNAMIC TABLE IF NOT EXISTS best_practice_insurance_dw.doc_ads_region_claim_analysis AS SELECT region_code, COUNT(*) AS total_policies, SUM(claim_status) AS total_claims, ROUND(SUM(claim_status) * 100.0 / COUNT(*), 4) AS claim_rate_pct, SUM(is_high_risk) AS high_risk_count, ROUND(AVG(subscription_length), 2) AS avg_policy_tenure, ROUND(AVG(vehicle_age), 2) AS avg_vehicle_age, SUM(CASE WHEN ncap_rating >= 3 THEN 1 ELSE 0 END) AS high_safety_policies, ROUND(AVG(ncap_rating), 2) AS avg_ncap_rating FROM best_practice_insurance_dw.doc_dwd_policy_lifecycle GROUP BY region_code;

REFRESH DYNAMIC TABLE best_practice_insurance_dw.doc_ads_region_claim_analysis; SELECT region_code, total_policies, total_claims, claim_rate_pct, high_risk_count, avg_ncap_rating FROM best_practice_insurance_dw.doc_ads_region_claim_analysis ORDER BY total_policies DESC LIMIT 10;

region_code | total_policies | total_claims | claim_rate_pct | high_risk_count | avg_ncap_rating ------------+----------------+--------------+----------------+-----------------+---------------- C2 | 21 | 2 | 9.5238 | 6 | 1.86 C8 | 18 | 0 | 0.0000 | 4 | 2.22 C3 | 16 | 1 | 6.2500 | 10 | 0.94 C5 | 10 | 1 | 10.0000 | 5 | 1.2 C13 | 9 | 0 | 0.0000 | 3 | 1.78 C9 | 4 | 0 | 0.0000 | 2 | 1.25 C15 | 4 | 0 | 0.0000 | 1 | 1.5 C10 | 4 | 1 | 25.0000 | 1 | 2 C14 | 3 | 0 | 0.0000 | 0 | 3 C19 | 3 | 0 | 0.0000 | 1 | 1.67

结果解读:C2 地区保单最多(21 张),理赔率 9.5%,高风险保单 6 张,是整体风险敞口最大的地区。C3 地区高风险保单 10 张(占比 62.5%),NCAP 均分仅 0.94,反映该地区车辆安全配置偏低,建议通过费率调整疏导风险。

保龄与年龄交叉风险分析

这是合规报表中最常见的交叉维度,用于识别高风险客群:

SELECT age_group, policy_tenure_group, COUNT(*) AS policy_count, SUM(claim_status) AS claim_count, ROUND(SUM(claim_status) * 100.0 / COUNT(*), 4) AS claim_rate_pct FROM best_practice_insurance_dw.doc_dwd_policy_lifecycle GROUP BY age_group, policy_tenure_group ORDER BY claim_rate_pct DESC;

age_group | policy_tenure_group | policy_count | claim_count | claim_rate_pct ----------------+---------------------+--------------+-------------+--------------- Middle (30-44) | Long (7+yr) | 26 | 3 | 11.5385 Senior (45-59) | Short (<3yr) | 14 | 1 | 7.1429 Senior (45-59) | Long (7+yr) | 16 | 1 | 6.2500 Elderly (60+) | Medium (3-7yr) | 1 | 0 | 0.0000 Senior (45-59) | Medium (3-7yr) | 8 | 0 | 0.0000 Elderly (60+) | Short (<3yr) | 1 | 0 | 0.0000 Middle (30-44) | Medium (3-7yr) | 12 | 0 | 0.0000 Middle (30-44) | Short (<3yr) | 22 | 0 | 0.0000

结果解读中年(30–44 岁)+ 长期保单(7 年以上) 理赔率最高(11.5%),3 件理赔来自 26 张保单。这个群体保单年限长说明存量风险积累较多,建议在续保时做车辆状况重新评估。


调度刷新任务(Studio Task)

Dynamic Table DDL 中不写

REFRESH INTERVAL
REFRESH INTERVAL
,而是在 Studio 创建 SQL 类型的调度任务。这样做的好处是:同一任务上可以追加监控告警、数据质量检查规则。

先创建用于保存任务的 Studio 文件夹,并记录返回的文件夹 ID。不同客户环境中的文件夹 ID 不同,后续

--folder
--folder
必须替换为本次创建得到的 ID:

cz-cli task create-folder "best_practices_insurance_dw" -p skill_test

示例返回:

{"data":187113}

下面示例用 shell 变量保存文件夹 ID;如果不使用变量,也可以直接把

${TASK_FOLDER_ID}
${TASK_FOLDER_ID}
替换成实际 ID:

TASK_FOLDER_ID=187113

在该文件夹下创建三个调度任务:

DWD 刷新任务(每天 02:00 执行)

cz-cli task create "refresh_dwd_policy_lifecycle" --type SQL --folder ${TASK_FOLDER_ID} -p skill_test cz-cli task save-content "refresh_dwd_policy_lifecycle" \ --content "REFRESH DYNAMIC TABLE best_practice_insurance_dw.doc_dwd_policy_lifecycle;" \ -p skill_test cz-cli task save-cron "refresh_dwd_policy_lifecycle" --cron "0 2 * * *" -p skill_test

DWS 刷新任务(每天 03:00 执行,依赖 DWD 任务完成)

cz-cli task create "refresh_dws_product_region_daily" --type SQL --folder ${TASK_FOLDER_ID} -p skill_test cz-cli task save-content "refresh_dws_product_region_daily" \ --content "REFRESH DYNAMIC TABLE best_practice_insurance_dw.doc_dws_product_region_daily;" \ -p skill_test cz-cli task save-cron "refresh_dws_product_region_daily" --cron "0 3 * * *" -p skill_test

ADS 刷新任务(每天 04:00 执行,依赖 DWS 任务完成)

cz-cli task create "refresh_ads_regulatory_report" --type SQL --folder ${TASK_FOLDER_ID} -p skill_test cz-cli task save-content "refresh_ads_regulatory_report" \ --content "REFRESH DYNAMIC TABLE best_practice_insurance_dw.doc_ads_regulatory_report; REFRESH DYNAMIC TABLE best_practice_insurance_dw.doc_ads_region_claim_analysis;" \ -p skill_test cz-cli task save-cron "refresh_ads_regulatory_report" --cron "0 4 * * *" -p skill_test


Time Travel:月末核对与监管历史回溯

监管审计场景常需要精确还原特定时间点的数据状态。云器 Lakehouse 的 Time Travel 支持任意历史时间点查询,无需额外备份。

查看 ODS 表的版本历史:

DESC HISTORY best_practice_insurance_dw.doc_ods_insurance_policy;

version | time | total_rows | operation | user --------+-------------------------------+------------+--------------+------------ 11 | 2026-06-06T22:50:11.211 | 100 | INSERT_INTO | admin_user 10 | 2026-06-06T22:49:54.316 | 90 | INSERT_INTO | admin_user ... 1 | 2026-06-06T22:46:25.719 | 0 | CREATE | admin_user

还原特定时间点的数据状态(例如月末 T+1 同步完成的历史快照):

-- 查询数据写入40条时的历史快照 SELECT COUNT(*) AS historical_count FROM best_practice_insurance_dw.doc_ods_insurance_policy TIMESTAMP AS OF '2026-06-06T22:48:26.136';

historical_count ---------------- 40

月末对账典型用法

-- 比较本月末与上月末的理赔率差异 WITH current_month AS ( SELECT segment, SUM(claim_status) AS claims, COUNT(*) AS policies FROM best_practice_insurance_dw.doc_ods_insurance_policy GROUP BY segment ), last_month AS ( SELECT segment, SUM(claim_status) AS claims, COUNT(*) AS policies FROM best_practice_insurance_dw.doc_ods_insurance_policy TIMESTAMP AS OF '2026-06-06T22:48:26.136' -- 替换为上月末时间点 GROUP BY segment ) SELECT c.segment, c.policies AS curr_policies, c.claims AS curr_claims, l.policies AS prev_policies, l.claims AS prev_claims, ROUND((c.claims * 1.0 / c.policies - l.claims * 1.0 / l.policies) * 100, 4) AS claim_rate_delta_pct FROM current_month c LEFT JOIN last_month l ON c.segment = l.segment ORDER BY claim_rate_delta_pct DESC;


RBAC:细粒度权限分级

保险核心业务各部门对数据的访问权限差异显著:

角色访问范围典型需求
精算部(
role_actuarial
role_actuarial
ODS + DWD + DWS,可见
customer_age
customer_age
(原始值)
费率精算、风险建模
理赔部(
role_claims
role_claims
ODS + DWD,可见保单全字段,不可修改理赔处理、欺诈核查
合规部(
role_compliance
role_compliance
ADS 只读,不可见原始
customer_age
customer_age
监管报表生成、合规审查
IT 运维(
role_ops
role_ops
Schema 级别 DDL 权限,不可查询数据表结构管理、索引维护

创建角色并分配权限的示例:

-- 创建角色 CREATE ROLE IF NOT EXISTS role_compliance; CREATE ROLE IF NOT EXISTS role_actuarial; CREATE ROLE IF NOT EXISTS role_claims; -- 合规部:仅授权 ADS 层两张动态报表表的 SELECT 权限 GRANT SELECT ON DYNAMIC TABLE best_practice_insurance_dw.doc_ads_regulatory_report TO ROLE role_compliance; GRANT SELECT ON DYNAMIC TABLE best_practice_insurance_dw.doc_ads_region_claim_analysis TO ROLE role_compliance; -- 精算部:授权 ODS + DWD + DWS 的 SELECT,同时加入可见原始 customer_age 的白名单 GRANT SELECT ON TABLE best_practice_insurance_dw.doc_ods_insurance_policy TO ROLE role_actuarial; GRANT SELECT ON TABLE best_practice_insurance_dw.doc_dwd_policy_lifecycle TO ROLE role_actuarial; GRANT SELECT ON TABLE best_practice_insurance_dw.doc_dws_product_region_daily TO ROLE role_actuarial; -- 理赔部:授权 ODS + DWD 的 SELECT GRANT SELECT ON TABLE best_practice_insurance_dw.doc_ods_insurance_policy TO ROLE role_claims; GRANT SELECT ON TABLE best_practice_insurance_dw.doc_dwd_policy_lifecycle TO ROLE role_claims;


数仓对象总览

全部构建完成后,

best_practice_insurance_dw
best_practice_insurance_dw
Schema 下的对象:

SHOW TABLES IN best_practice_insurance_dw;

schema_name | table_name | is_dynamic -------------------------------+-----------------------------------+----------- best_practice_insurance_dw | doc_ods_insurance_policy | false best_practice_insurance_dw | doc_dwd_policy_lifecycle | true best_practice_insurance_dw | doc_dws_product_region_daily | true best_practice_insurance_dw | doc_ads_regulatory_report | true best_practice_insurance_dw | doc_ads_region_claim_analysis | true

数据链路:

Oracle / PostgreSQL(核心系统) │ ▼ T+1 批量全量同步 doc_ods_insurance_policy(ODS) Bloomfilter Index(policy_id) Column Masking(customer_age) │ ▼ Studio Task: refresh_dwd_policy_lifecycle(每天 02:00) doc_dwd_policy_lifecycle(DWD · Dynamic Table) age_group / vehicle_age_group / policy_tenure_group / is_high_risk │ ▼ Studio Task: refresh_dws_product_region_daily(每天 03:00) doc_dws_product_region_daily(DWS · Dynamic Table) segment × fuel_type × region_code · claim_rate_pct / high_risk_rate_pct │ ├──▶ doc_ads_regulatory_report(ADS · Dynamic Table) │ 产品盈利报表 · CBIRC 产品经营分析 │ └──▶ doc_ads_region_claim_analysis(ADS · Dynamic Table) 地区风险集中度报表 · CBIRC 地区风险监控 Studio Task: refresh_ads_regulatory_report(每天 04:00)


注意事项

  • Dynamic Table 不写 REFRESH INTERVAL:所有 Dynamic Table DDL 中均不写

    REFRESH INTERVAL
    REFRESH INTERVAL
    ,刷新调度通过 Studio Task 管理,这样可以在同一任务上附加监控告警和数据质量检查规则。

  • 分区 Dynamic Table 必须使用静态分区:如需对 ADS 层按月份分区,必须显式声明

    PARTITION BY
    PARTITION BY
    + 静态分区选项,不能使用动态分区推断。

  • Time Travel 时间戳限制

    TIMESTAMP AS OF
    TIMESTAMP AS OF
    只接受字面量常量,不支持
    NOW() - INTERVAL 1 MONTH
    NOW() - INTERVAL 1 MONTH
    等动态表达式;
    DESC HISTORY
    DESC HISTORY
    返回 UTC 时间,查询时注意本地时区偏差(默认 UTC+8)。

  • Column Masking 对 Dynamic Table 透明生效:DWD 层直接查询 ODS 时,非授权用户看到的

    customer_age
    customer_age
    是脱敏后的年龄段整数;DWD 中存储的值也是脱敏后的,精算层需要原始精度时应通过有权限账号直接查 ODS。

  • Bloomfilter Index 对存量数据不自动生效

    CREATE BLOOMFILTER INDEX
    CREATE BLOOMFILTER INDEX
    只对创建后写入的新数据生效;表中已有存量数据时 Bloomfilter 过滤加速效果有限,
    BLOOMFILTER
    BLOOMFILTER
    类型不支持
    BUILD INDEX
    BUILD INDEX
    ,如需覆盖存量数据需重建表。

  • RBAC 权限变更同步:Column Masking 白名单修改后立即生效,但 GRANT/REVOKE 权限变更在部分场景下可能需要用户重新登录会话才能感知。


相关文档

联系我们
预约咨询
微信咨询
电话咨询
邮件咨询