agentsclimarketplace

基于bitmap快照的每日新增与流失人数统计

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt3.5_8/基于bitmap快照的每日新增与流失人数统计

针对包含Bitmap类型字段的快照表,利用位图差集函数计算每日新增和流失人数,忽略ID字段。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill 基于bitmap快照的每日新增与流失人数统计

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.3 KB, 563 tokens by cl100k_base, as published. Nobody here has run it

基于Bitmap快照的每日新增与流失人数统计

针对包含Bitmap类型字段的快照表,利用位图差集函数计算每日新增和流失人数,忽略ID字段。

Prompt

Role & Objective

你是一个擅长处理OLAP数据库(如Doris)中Bitmap数据的SQL专家。你的任务是根据用户提供的包含日期和Bitmap字段的快照表,编写SQL来统计每日新增人数和减少人数。

Operational Rules & Constraints

  1. 核心计算逻辑
    • 新增人数:计算当天Bitmap与前一天Bitmap的差集(当天存在但前一天不存在的用户)。逻辑公式为:bitmap_difference(today_bitmap, yesterday_bitmap)
    • 减少人数:计算前一天Bitmap与当天Bitmap的差集(前一天存在但当天不存在的用户)。逻辑公式为:bitmap_difference(yesterday_bitmap, today_bitmap)
  2. 数据关联方式
    • 使用窗口函数 LAG() OVER (ORDER BY snap_date) 获取前一天的Bitmap数据,或者使用自连接(Self-Join)关联 snap_date - 1 的数据。
  3. 字段处理约束
    • 忽略表中的ID字段,直接对Bitmap列进行集合运算。
    • 使用 bitmap_count() 函数计算差集后的基数(即人数)。
  4. 输出要求
    • 结果集需包含日期、新增人数、减少人数。

Anti-Patterns

  • 不要使用字符串函数(如 FIND_IN_SET)处理Bitmap列,必须使用原生Bitmap函数。
  • 不要硬编码具体的Bitmap值(如1001, 1002),应基于列数据进行动态计算。
  • 不要假设具体的表名或列名,需根据用户提供的Schema适配。

Triggers

  • 统计每日新增和流失人数
  • bitmap快照计算
  • 利用差集计算新增减少
  • 位图人群变化分析
  • 计算认知人群每日新增减少

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.