agentsclimarketplace

Sql standards

Skill deletexiumu/AgentSkills-Hub/skills/public/smart-data-query/skills/sql-standards

SQL output standards and Hive dialect compatibility rules for data warehouse queries. This skill should be used when generating SQL for Hive/SparkSQL/GaussDB, or when reviewing SQL for compatibility issues.From its SKILL.md

Install
npx -y skills add deletexiumu/AgentSkills-Hub --skill sql-standards

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

2 things 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.
  • 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.4 KB, as published. Nobody here has run it

SQL 标准规范

生成数仓 SQL 时必须遵守的输出规范、方言规则和验收要求。

输出规范

  • 可直接执行:完整 SQL(允许 CTE),不输出伪代码
  • 参数清晰:可变参数用 {{start_date}} 占位符,注释说明格式
  • 字段命名一致:输出字段与需求字段一一对应
  • 分区可下推:用分区字段(dt/ds/biz_date)过滤,避免全表扫描
  • 中文别名:最终 SELECT 用中文别名,Hive 用 `中文`,GaussDB 用 "中文"

CTE 推荐结构

  1. base:事实表取数(必要列 + 分区过滤 + 业务过滤)
  2. agg:按需求粒度聚合
  3. dim_*:维度补充(先去重/取最新再 join)
  4. final:整理输出字段、排序

Hive 低版本兼容性

禁止的语法

禁止项替代方案
TRANSFORM 函数LATERAL VIEW EXPLODE、regexp_extract、get_json_object
SELECT/JOIN ON 中的子查询 (select ...)派生表 / CTE 先算好再 JOIN
ORDER BY 1, 2, 3 序号排序用输出列名排序

ORDER BY 规则

ORDER BY 必须只引用当前 SELECT 的输出列名。如果用了中文别名,必须用中文别名排序:

-- 正确
SELECT province_name AS `省份`, COUNT(*) AS `数量`
FROM t GROUP BY province_name
ORDER BY `省份`

-- 错误:用底层字段名
ORDER BY province_name

验收要点

  • 禁用 select *,显式列出输出字段
  • group by 与选择列一致,聚合指标不重复计算
  • join 时写清类型与 key,维表多版本先去重再 join
  • 默认 Hive/SparkSQL 方言,GaussDB 仅按需输出
  • 口径不确定时给多分支 SQL 或注释说明假设

详细文档

主题路径
SQL 输出规范references/SQL-输出规范.md
方言兼容references/方言与兼容性.md
静态验收清单references/静态验收清单.md
日志迭代references/日志与迭代机制.md
需求问卷references/问数需求问卷模板.md

Keep looking

Skills are one crate of 609,856. 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.