diff --git a/scripts/af_click_gap_pipeline.py b/scripts/af_click_gap_pipeline.py index 74568db..6512dc4 100755 --- a/scripts/af_click_gap_pipeline.py +++ b/scripts/af_click_gap_pipeline.py @@ -101,9 +101,6 @@ def validate_existing_schema(path: str) -> None: primary_key = [(row[1], row[5]) for row in columns if row[5]] if primary_key != [("pid", 1), ("dt", 2), ("pkg_name", 3)]: raise RuntimeError("click_gap 主键必须为 (pid, dt, pkg_name)") - required = {"pid", "dt", "pkg_name", "shareit_clicks", "af_clicks", "installs_ua", "clicks_diff", "updated_at"} - if any(by_name[name][3] != 1 for name in required): - raise RuntimeError("click_gap 必填列不得允许 NULL") def read_rows(path: str, start: str, end: str, pid: str = PID) -> list[dict[str, Any]]: @@ -127,8 +124,10 @@ def validate_rows(rows: list[dict[str, Any]], start: str, end: str) -> list[dict if list(row) != REPORT_COLUMNS: raise ValueError("报告字段不合法") normalized_row = dict(row) + normalized_row["attr_platform"] = "" if row["attr_platform"] is None else row["attr_platform"] + normalized_row["pkg_name"] = "" if row["pkg_name"] is None else row["pkg_name"] normalized_row["dt"] = date8(str(row["dt"])) - if not start <= normalized_row["dt"] <= end or not str(row["attr_platform"]).strip() or not str(row["pkg_name"]).strip(): + if not start <= normalized_row["dt"] <= end or not str(normalized_row["pkg_name"]).strip(): raise ValueError("报告日期、平台或包名不合法") for field in REPORT_COLUMNS[3:]: normalized_row[field] = finite_number(row[field], field, field == "clicks_diff_rate")