Huawei Cloud Dws Sql Check 标志

Huawei Cloud Dws Sql Check

组织
huaweicloud
huawei-cloud-dws-sql-check

Comprehensive SQL statement checking for DWS, supporting two check modes: 1. Syntax Check - Keyword validation, statement structure verification, clause completeness, DWS syntax compatibility based on gram.y grammar definitions 2. Specification Check - Object design standards, data operation standards, naming conventions based on DWS development design specification Built-in custom DWS SQL tokenizer (594 keywords) and recursive descent parser supporting 160+ statement types. Applicable when users need SQL quality review, syntax validation, or specification compliance checking. 触发词:"SQL检查"、"SQL规范"、"SQL审计"、"SQL语法"、"SQL优化"、"检查SQL"、"SQL review"

概览

发布者huaweicloud
代码仓库huaweicloud-skills
技能名称huawei-cloud-dws-sql-check
星标数
59
复刻数
24
附带文件
10
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 10 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 huaweicloud 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Huawei Cloud Dws Sql Check AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/huaweicloud/huaweicloud-skills/tree/master/skills/bigdata/dws/huawei-cloud-dws-sql-check
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/huaweicloud/huaweicloud-skills.git /tmp/huaweicloud-skills
mkdir -p .claude/skills
cp -r /tmp/huaweicloud-skills/skills/bigdata/dws/huawei-cloud-dws-sql-check .claude/skills/huawei-cloud-dws-sql-check
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Huawei Cloud Dws Sql Check,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Huawei Cloud Dws Sql Check。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Huawei Cloud Dws Sql Check 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

DWS SQL Check Skill

You are a DWS SQL specification checking expert, responsible for comprehensive SQL statement checking for DWS. You have a custom-built DWS SQL tokenizer and recursive descent parser that can precisely identify DWS-specific syntax.

Overview

Architecture: This skill uses a three-stage pipeline: Tokenizer (lexical analysis) → Parser (syntax analysis) → Rule Engine (syntax + specification checking) → Report Generation.

Applicable Scenarios:

  • Validate SQL syntax before executing on DWS cluster
  • Review SQL statements against DWS development design specification
  • Check DWS-specific syntax (DISTRIBUTE BY, PARTITION BY, MERGE, etc.)
  • Identify potential performance anti-patterns in SQL statements

Typical Use Cases:

  • "Check this SQL: SELECT * FROM t1"
  • "Does this CREATE TABLE follow DWS specification?"
  • "Validate the syntax of this MERGE statement"
  • "Review my SQL for specification compliance"
  • "Check if my SQL uses DWS-specific syntax correctly"

Check Modes

ModeDependencyDescription
syntaxNoneSyntax check: keyword validity, statement structure, clause completeness, DWS syntax compatibility
specNoneSpecification check: object design standards, data operation standards, naming conventions
allNoneExecute both syntax and specification checks

Default: syntax + spec mode (no external dependencies required).

Prerequisites

1. Python Requirements

  • Python >= 3.8
  • No additional packages required (standard library only)

2. Security Rules

  • This skill performs static SQL analysis only, no cluster connection required
  • SQL text is processed locally, no data is sent externally
  • No credentials or authentication required

Workflow

Step 1: Receive Input

Receive the SQL statement and check mode from the user. If no mode is specified, default to syntax + spec.

Step 2: Tokenization

Run the tokenizer to convert SQL text into a Token stream.

bash
python ~/.cac/skills/huawei-cloud-dws-sql-check/scripts/dws_sql_tokenizer.py "<sql_text>"

The tokenizer supports:

  • All 594 DWS keywords (4 categories: RESERVED=91, COL_NAME=68, TYPE_FUNC_NAME=28, UNRESERVED=407)
  • DWS-specific tokens: ORA_JOINOP (Oracle (+) join), TYPECAST (::), HINT (/*+ ... */)
  • Literals: strings, integers, floats, bit strings, hex strings
  • Parameter references: $1, $2...
  • Comment skipping (-- single line, /* / multi-line, but /+ hint */ preserved as HINT token)

Step 3: Parsing

Run the parser to generate AST and detect syntax errors.

bash
python ~/.cac/skills/huawei-cloud-dws-sql-check/scripts/dws_sql_parser.py "<sql_text>"

The parser supports major statement types:

  • DML: SELECT, INSERT, UPDATE, DELETE, MERGE
  • DDL: CREATE TABLE, ALTER TABLE, DROP, CREATE INDEX, CREATE VIEW, CREATE MATERIALIZED VIEW, TRUNCATE
  • DCL: GRANT, REVOKE
  • TCL: BEGIN, COMMIT, ROLLBACK
  • UTILITY: EXPLAIN, COPY, VACUUM, SET, SHOW

DWS-specific syntax:

  • DISTRIBUTE BY {HASH|MODULO|REPLICATION|ROUNDROBIN}
  • PARTITION BY {RANGE|LIST|INTERVAL}
  • TO {NODE|GROUP}
  • COMPRESS {YES|NO}
  • TIMECAPSULE TABLE ... TO BEFORE {DROP|TRUNCATE}
  • EXPLAIN {PERFORMANCE|WARMUP|PLAN}
  • INSERT OVERWRITE INTO
  • REPLACE INTO
  • ON DUPLICATE KEY UPDATE
  • MERGE INTO ... USING ... ON ... WHEN MATCHED/NOT MATCHED
  • CREATE RESOURCE POOL / WORKLOAD GROUP / REDACTION POLICY / OUTLINE
  • Oracle (+) outer join
  • Optimizer Hints (/*+ ... */)

Step 4: Syntax Check

Based on tokenization and parsing results, execute syntax check rules.

Syntax Check Rules (19 rules):

Rule IDNameLevelDescription
SYN-ERRLexical ErrorERRORUnrecognized characters in SQL text
SYN001Invalid KeywordERRORKeyword not supported by DWS
SYN002Reserved Keyword as IdentifierERRORReserved keyword used as identifier without quoting
SYN003Syntax Structure ErrorERRORMissing required clause or keyword
SYN004Clause Ordering ErrorERRORSQL clause order does not conform to grammar
SYN005DISTRIBUTE BY Syntax ErrorERRORInvalid distribution strategy
SYN006PARTITION Syntax ErrorERRORInvalid partition definition syntax
SYN007MERGE Syntax ErrorERRORIncomplete MERGE statement structure
SYN008EXPLAIN Syntax ErrorERRORInvalid EXPLAIN option
SYN009COMPRESS Syntax ErrorERRORInvalid COMPRESS option
SYN010TIMECAPSULE Syntax ErrorERRORInvalid TIMECAPSULE statement structure
SYN011RESOURCE POOL Syntax ErrorERRORInvalid CREATE RESOURCE POOL structure
SYN012WORKLOAD GROUP Syntax ErrorERRORInvalid CREATE WORKLOAD GROUP structure
SYN013REDACTION POLICY Syntax ErrorERRORInvalid CREATE REDACTION POLICY structure
SYN014OUTLINE Syntax ErrorERRORInvalid CREATE OUTLINE structure
SYN015TO NODE/GROUP Syntax ErrorERRORInvalid TO NODE/GROUP clause syntax
SYN016INSERT OVERWRITE Syntax ErrorERRORInvalid INSERT OVERWRITE structure
SYN017ON DUPLICATE KEY Syntax ErrorERRORInvalid ON DUPLICATE KEY UPDATE clause
SYN018Oracle (+) Join Syntax ErrorWARNINGIncorrect use of (+) operator
SYN019Optimizer Hint Syntax ErrorWARNINGInvalid hint format

Step 5: Specification Check

Based on AST and Token stream, execute specification check rules. Rules are derived from gram.y grammar definitions and DWS development design specification.

Specification Check Rules (40 rules):

Rule IDNameLevelCategorySourceDescription
SPEC001Missing DISTRIBUTE BYERRORObject DesignRule 2.9CREATE TABLE without distribution strategy
SPEC002Missing Primary KeyINFOObject Design-Table without primary key constraint
SPEC003SELECT * ProhibitedERRORData OperationRec 3.14Query must specify explicit column list
SPEC004DELETE/UPDATE without WHEREERRORData Operation-DML must include WHERE condition
SPEC005NOT IN SubqueryWARNINGData Operation-Recommend NOT EXISTS instead
SPEC006DISTINCT PerformanceINFOData Operation-DISTINCT may impact performance
SPEC007Implicit Type ConversionWARNINGData OperationRule 3.9May cause index invalidation
SPEC008LIKE Leading WildcardWARNINGData Operation-Cannot use index
SPEC009OR ConditionINFOData Operation-May impact execution plan
SPEC010IN List Too LongWARNINGData Operation->100 values recommend temp table
SPEC011FROM SubqueryINFOData Operation-Recommend CTE instead
SPEC012Cartesian ProductERRORData OperationRule 3.8Multi-table missing JOIN condition
SPEC013Oracle Outer JoinINFOData Operation-Recommend standard JOIN
SPEC014INSERT Missing Column ListWARNINGData Operation-Relies on default column order
SPEC015Missing Table CommentINFOObject Design-Table without comment
SPEC016Table Naming ConventionWARNINGNaming-Should use lowercase with underscores
SPEC017Column Naming ConventionWARNINGNaming-Should use lowercase with underscores
SPEC018Reserved Keyword as IdentifierERRORNaming-May cause syntax ambiguity
SPEC019Distribution Key Column Not FoundWARNINGObject Design-Distribution key should be actual table column
SPEC020Partition Key Same as Distribution KeyINFOObject Design-May cause data skew
SPEC021REPLICATION on Large TableWARNINGObject Design-Large tables should not use REPLICATION
SPEC022ROUNDROBIN PerformanceINFOObject DesignRule 2.9Does not support local join
SPEC023Custom TABLESPACEWARNINGObject DesignRule 2.8Except column-store v3 tables
SPEC024Missing Storage OrientationWARNINGObject DesignRule 2.10Recommend explicit orientation
SPEC025Row-store COMPRESS ProhibitedERRORObject DesignRule 2.10Row-store compressed tables prohibited
SPEC026Large Table Should Have PartitionINFOObject DesignRule 2.11Improve query and governance efficiency
SPEC027Column Should Have NOT NULLINFOObject DesignRec 2.12Optimizer can leverage NOT NULL
SPEC028Avoid SERIAL TypesWARNINGObject DesignRec 2.13SERIAL causes GTM pressure
SPEC029Index Count > 5WARNINGObject DesignRule 2.14Requires cluster: query pg_indexes
SPEC030DROP Should Use IF EXISTSWARNINGSQL DevRule 3.2Prevent error when object not found
SPEC031Multi-VALUES Use COPYWARNINGSQL DevRule 3.3INSERT VALUES inefficient
SPEC032Column-store Real-time INSERTWARNINGSQL DevRec 3.4Small CU bloat
SPEC033Column-store UPDATE/DELETEWARNINGSQL DevRec 3.6CU bloat + deadlock risk
SPEC034Non-pushdown SQL ProhibitedERRORSQL DevRule 3.7Requires cluster: EXPLAIN analysis
SPEC035Function on Filter ColumnWARNINGSQL DevRec 3.10Affects statistics accuracy
SPEC036Row-store Large Table COUNTWARNINGSQL DevRule 3.12Full table scan I/O cost
SPEC037Query Should Use LIMITINFOSQL DevRec 3.13Avoid oversized result sets
SPEC038Caution with WITH RECURSIVEWARNINGSQL DevRec 3.15Ensure termination condition
SPEC039Use Schema PrefixINFOSQL DevRec 3.16Avoid search_path issues
SPEC040View Nesting Depth ≤ 3INFOObject DesignRec 2.16Requires cluster: query view dependencies

Step 6: Generate Report

Use the check engine to generate a Markdown format report:

bash
python ~/.cac/skills/huawei-cloud-dws-sql-check/scripts/dws_sql_checker.py "<sql_text>" all

Report format:

markdown
# DWS SQL Check Report

**Check Time**: 2026-06-18T10:00:00
**Statement Type**: SELECT
**Check Mode**: all

## Summary

| Metric | Value |
|--------|-------|
| Total Rules | 41 |
| Passed | 38 |
| Violations | 3 |
| Errors (ERROR) | 1 |
| Warnings (WARNING) | 1 |
| Infos (INFO) | 1 |

## Syntax Check

### [X] SYN003: Syntax Structure Error
- **Level**: ERROR
- **Position**: Line 1, Column 15
- **Description**: Missing FROM clause
- **Fix Suggestion**: Add FROM table_name

## Specification Check

### [!] SPEC003: SELECT * Prohibited
- **Level**: WARNING
- **Position**: Line 1, Column 8
- **Description**: Query uses SELECT *, should specify explicit column list
- **Fix Suggestion**: Replace SELECT * with specific column list

Parameters

ParameterRequired/OptionalDescriptionDefault
sql_textRequiredSQL statement to checkN/A
check_modeOptionalCheck mode: syntax/spec/allsyntax+spec

Output Format

The check report is output in Markdown format, containing:

  • Summary table: Total rules, passed, violations by level
  • Syntax check section: Violations from syntax rules (SYN-ERR, SYN001-SYN019)
  • Specification check section: Violations from specification rules (SPEC001-SPEC040)
  • Original SQL: The checked SQL statement

Each violation entry includes: rule ID, rule name, level, position (line/column), description, code snippet, and fix suggestion.

Quick Check Command

For simple SQL checks, run directly:

bash
python ~/.cac/skills/huawei-cloud-dws-sql-check/scripts/dws_sql_checker.py "<sql_text>" [syntax|spec|all]

Output is in JSON format. For Markdown format report, call in Python:

python
from dws_sql_checker import check_sql_markdown
report = check_sql_markdown("SELECT * FROM t1", "all")
print(report)

Best Practices

  1. Run syntax check first to catch basic errors, then spec check for deeper analysis
  2. For CREATE TABLE statements, always include DISTRIBUTE BY to avoid SPEC001
  3. Use all mode for comprehensive checking
  4. Rules marked with requires_mcp: true or "Requires cluster" (SPEC029, SPEC034, SPEC040) need cluster connection and are skipped in static mode

References

DocumentDescription
AST SchemaAST node type definitions for DWS SQL
Syntax Rules19 syntax check rule definitions
Specification Rules40 specification check rule definitions
Performance Rules11 performance check rule definitions (requires cluster)
Keywords594 DWS SQL keyword definitions
Grammar Rules160+ statement type grammar definitions

Notes

  1. Syntax and specification checks do not require cluster connection, can run offline
  2. Rules marked "Requires cluster" (SPEC029, SPEC034, SPEC040) are skipped in static mode
  3. Performance rules (PERF001-PERF011) are defined in rules/perf_rules.yaml but require cluster connection for execution
  4. DWS-specific syntax checking (DISTRIBUTE BY, PARTITION BY, MERGE, etc.) is based on gram.y grammar definitions
  5. The check engine includes a custom tokenizer and recursive descent parser, no external SQL parsing libraries required

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Huawei Cloud Dws Sql Check AI 技能有什么作用?

Comprehensive SQL statement checking for DWS, supporting two check modes: 1. Syntax Check - Keyword validation, statement structure verification, clause completeness, DWS syntax compatibility based on gram.y grammar definitions 2. Specification Check - Object design standards, data operation standards, naming conventions based on DWS development design specification Built-in custom DWS SQL tokenizer (594 keywords) and recursive descent parser supporting 160+ statement types. Applicable when users need SQL quality review, syntax validation, or specification compliance checking. 触发词:"SQL检查"、"...

为什么在 TypingMind 中使用 Huawei Cloud Dws Sql Check?

因为您只需安装一次,就能搭配任何模型使用。Huawei Cloud Dws Sql Check 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Huawei Cloud Dws Sql Check?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/huaweicloud/huaweicloud-skills/tree/master/skills/bigdata/dws/huawei-cloud-dws-sql-check。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Huawei Cloud Dws Sql Check?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Huawei Cloud Dws Sql Check 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Huawei Cloud Dws Sql Check 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Huawei Cloud Dws Sql Check AI 技能免费吗?

是的。huaweicloud 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇