-- 验证：sample_all 表 scoresmap 实际 key 全集 vs SQL 清单
-- 取每个 (apptype, abcode) 一条样本，便于读取 raw JSON 列举所有 key
WITH t_sample AS
(
    SELECT  apptype
            ,abcode
            ,REPLACE(GET_JSON_OBJECT(extend_alg,'$.scoresMap'),"\\","") AS scoresmap
            ,ROW_NUMBER() OVER (PARTITION BY apptype, abcode ORDER BY ts) AS rn
    FROM    loghubods.dwd_recsys_alg_sample_all_20250212
    WHERE   dt = '${dt}'
    AND     apptype IN ('0','4')
    AND     abcode IN ('ab0','ab1','ab2','ab3','ab4','ab5','ab6','ab7','ab8','ab9')
    AND     extend_alg IS NOT NULL
    AND     GET_JSON_OBJECT(extend_alg,'$.scoresMap') IS NOT NULL
)
SELECT  apptype, abcode, scoresmap
FROM    t_sample
WHERE   rn = 1
ORDER BY apptype, abcode
;
