Logo de Huawei Cloud Mrs Hive Sql Check

Huawei Cloud Mrs Hive Sql Check

Organização
huaweicloud
huawei-cloud-mrs-hive-sql-check

Huawei Cloud MRS Hive SQL specification checking skill. Checks SQL statements against defined syntax and specification rules using the automated checker engine. No extra manual analysis beyond defined rules. Trigger:"Hive SQL优化"、"检查Hive SQL"、"Hive SQL检查"、"Hive SQL规范"、"Hive SQL语法"、"Hive SQL review"

Visão geral

Publicado porhuaweicloud
Repositóriohuaweicloud-skills
Nome da habilidadehuawei-cloud-mrs-hive-sql-check
Estrelas
59
Forks
24
Arquivos incluídos
14
LicençaMIT
Links
  • Instruções em Markdown

    Um arquivo SKILL.md que o modelo carrega sob demanda, consumindo tokens apenas quando uma solicitação é realmente relevante para a habilidade.

  • Funciona com qualquer LLM

    As habilidades de IA são escritas em Markdown simples, não em código específico de um provedor. Por isso, funcionam com GPT, Claude, Gemini, Grok ou um modelo local.

  • Arquivos incluídos: 14

    Scripts, templates e referências que o modelo pode ler enquanto trabalha. Os arquivos são somente para leitura e nunca são executados.

  • Código aberto

    Publicada por huaweicloud no GitHub. Leia os arquivos da habilidade antes de instalá-la.

Instalação

Instale a habilidade de IA Huawei Cloud Mrs Hive Sql Check no TypingMind para usá-la com qualquer LLM ou adicione-a a outro agente que leia SKILL.md.

1

Instalar no TypingMind

O TypingMind instala uma habilidade diretamente da pasta dela no GitHub — lê o arquivo SKILL.md, reúne os arquivos de recursos em um pacote e armazena o resultado localmente.

  1. Abra o app e vá para Plugins → Habilidades.
  2. Escolha "Instalar do GitHub".
  3. Cole a URL abaixo, que aponta para a pasta da habilidade, e confirme.
    https://github.com/huaweicloud/huaweicloud-skills/tree/master/skills/bigdata/mrs/huawei-cloud-mrs-hive-sql-check
  4. Ative a habilidade em cada chat em que quiser disponibilizá-la.
Plugins → Habilidades → Adicionar habilidade → Via URL do GitHub. Depois, cole a URL da pasta e pressione Continuar.
2

Instalar em outro agente

Qualquer agente que leia o formato Agent Skills pode usar esta habilidade — copie a pasta para o diretório de habilidades desse agente.

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/mrs/huawei-cloud-mrs-hive-sql-check .claude/skills/huawei-cloud-mrs-hive-sql-check
Reinicie Claude Code após copiar para que a nova habilidade seja reconhecida.

Use no TypingMind

Ative Huawei Cloud Mrs Hive Sql Check em qualquer chat do TypingMind e o modelo cuida do resto. O nome e a descrição da habilidade ficam no prompt do sistema e, assim que uma solicitação relevante aparece, o modelo carrega as instruções completas automaticamente — sem precisar de acionamento manual e sem consumir tokens até que ela seja realmente usada.

O modelo carrega Huawei Cloud Mrs Hive Sql Check automaticamente assim que uma solicitação é relevante para essa habilidade.

Funciona com qualquer modelo de IA

Habilidades de IA são instruções em Markdown simples, não código específico de um provedor. Por isso, Huawei Cloud Mrs Hive Sql Check não fica vinculada ao modelo para o qual foi criada. Instale-a uma vez no TypingMind e use-a com GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou um modelo local executado por conta própria — tudo com suas próprias chaves de API.

  • Carregada apenas quando necessário

    O prompt do sistema contém apenas o nome e a descrição. As instruções são buscadas na primeira solicitação relevante, então uma habilidade sem uso não gera custo.

  • Troque de modelo durante a conversa

    Como a habilidade é composta de instruções, não de código, trocar de modelo não afeta seu funcionamento — o próximo modelo lê o mesmo arquivo SKILL.md.

Instruções da habilidade

Este é o conteúdo de SKILL.md que o modelo carrega. Leia antes de instalar — uma habilidade é um conjunto de instruções que seu modelo seguirá.

MRS Hive SQL Check Skill

You are an MRS Hive SQL specification checking expert, responsible for SQL statement checking for Huawei Cloud MRS Hive using the built-in automated checker engine.

CRITICAL CONSTRAINT: No Extra Analysis

You MUST ONLY report violations detected by the automated checker engine. Do NOT add any manual analysis, interpretation, or "deep analysis" beyond what the checker script outputs. This includes but is not limited to:

  • Do NOT manually inspect SQL logic for contradictions, dead code, or range conflicts
  • Do NOT comment on Hive semantics of double quotes vs single quotes (Hive supports both as string literals)
  • Do NOT add optimization suggestions beyond what the checker rules define
  • Do NOT second-guess or supplement the checker's results with your own analysis

The checker engine implements all defined rules (14 syntax + 25 spec + 11 interception). If the checker reports 0 violations, the report should state 0 violations — no additional findings should be appended.

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 MRS Hive cluster
  • Review SQL statements against Hive development specification
  • Check Hive-specific syntax (PARTITIONED BY, CLUSTERED BY, STORED AS, ROW FORMAT, etc.)
  • Detect large SQL interception risks based on defined rules

Typical Use Cases:

  • "Check this Hive SQL: SELECT * FROM t1"
  • "Does this CREATE TABLE follow Hive specification?"
  • "Validate the syntax of this INSERT OVERWRITE statement"
  • "Review my Hive SQL for specification compliance"
  • "Check if my SQL has partition pruning issues"

Check Modes

ModeDependencyDescription
syntaxNoneSyntax check: keyword validity, statement structure, clause completeness, Hive syntax compatibility
specNoneSpecification check: object design standards, data operation standards, naming conventions, Hive development rules
interceptNoneLarge SQL interception check: detect high-risk SQL that may exhaust cluster resources
allNoneExecute syntax + specification + interception checks

Default: all 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(s) and check mode from the user. If no mode is specified, default to all (syntax + spec + intercept).

IMPORTANT: Multi-statement Context: When the user provides multiple SQL statements (separated by ;), you MUST pass ALL statements together in a single checker call. Do NOT split and check them individually. The checker engine has built-in multi-statement support that:

  1. First pass: Scans all CREATE TABLE ... PARTITIONED BY statements to build a partitioned table registry (table names + partition field names)
  2. Second pass: Checks each statement independently, but shares the partitioned table context so that SELECT/INSERT statements referencing partitioned tables can trigger SPEC022 (partition pruning missing)

This is critical for rules like SPEC022 (partition pruning) which require knowing whether a table is partitioned — information that only exists in CREATE TABLE statements, not in the SELECT statement itself.

Correct: Pass all SQL together:

bash
python ~/.cac/skills/huawei-cloud-mrs-hive-sql-check/scripts/hive_sql_checker.py "create table t(name string) partitioned by(dt string); select name from t;" all

Wrong: Split and check individually (SPEC022 will be missed):

bash
python ~/.cac/skills/huawei-cloud-mrs-hive-sql-check/scripts/hive_sql_checker.py "create table t(name string) partitioned by(dt string);" all
python ~/.cac/skills/huawei-cloud-mrs-hive-sql-check/scripts/hive_sql_checker.py "select name from t;" all

Step 2: Tokenization

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

bash
python ~/.cac/skills/huawei-cloud-mrs-hive-sql-check/scripts/hive_sql_tokenizer.py "<sql_text>"

The tokenizer supports:

  • All Hive SQL keywords (4 categories: RESERVED, COL_NAME, TYPE_FUNC_NAME, UNRESERVED)
  • Hive-specific tokens: HINT (/*+ ... */), BACKTICK_IDENT (`ident`)
  • Literals: strings, integers, floats
  • 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-mrs-hive-sql-check/scripts/hive_sql_parser.py "<sql_text>"

The parser supports major statement types:

  • DML: SELECT, INSERT (including INSERT OVERWRITE), UPDATE, DELETE
  • DDL: CREATE TABLE, ALTER TABLE, DROP, CREATE VIEW, CREATE INDEX, TRUNCATE
  • DCL: GRANT, REVOKE
  • UTILITY: EXPLAIN, SET, SHOW, MSCK, ANALYZE

Hive-specific syntax:

  • PARTITIONED BY (col type, ...)
  • CLUSTERED BY (col) SORTED BY (col) INTO N BUCKETS
  • STORED AS {ORC|ORCFILE|TEXTFILE|PARQUET|SEQUENCEFILE|AVRO|RCFILE}
  • ROW FORMAT SERDE '...' STORED AS INPUTFORMAT '...' OUTPUTFORMAT '...'
  • LOCATION 'hdfs_path'
  • TBLPROPERTIES ('key'='value', ...)
  • INSERT OVERWRITE TABLE ... PARTITION (...)
  • /*+ MAPJOIN(table) */ and /*+ STREAMTABLE(table) */ hints
  • LATERAL VIEW ... EXPLODE(...)
  • LATERAL TABLE
  • FROM ... INSERT OVERWRITE ... SELECT ... (multi-insert)

Step 4: Syntax Check

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

Syntax Check Rules (14 rules):

Rule IDNameLevelDescription
SYN-ERRLexical ErrorERRORUnrecognized characters in SQL text
SYN001Invalid KeywordERRORKeyword not supported by Hive
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
SYN005PARTITIONED BY Syntax ErrorERRORInvalid partition definition syntax
SYN006CLUSTERED BY Syntax ErrorERRORInvalid bucket definition syntax
SYN007STORED AS Syntax ErrorERRORInvalid storage format
SYN008ROW FORMAT Syntax ErrorERRORInvalid ROW FORMAT definition
SYN009INSERT OVERWRITE Syntax ErrorERRORInvalid INSERT OVERWRITE structure
SYN010LATERAL VIEW Syntax ErrorERRORInvalid LATERAL VIEW structure
SYN011Subquery Syntax ErrorERRORInvalid subquery structure
SYN012CREATE TABLE Structure ErrorERRORMissing required elements in CREATE TABLE (columns, AS SELECT, LIKE, TBLPROPERTIES, ROW FORMAT SERDE, or STORED BY)
SYN013ALTER TABLE Syntax ErrorERRORInvalid ALTER TABLE action

Step 5: Specification Check

Based on AST and Token stream, execute specification check rules. Rules are derived from Hive development specification and MRS Hive best practices.

Specification Check Rules (25 rules):

Rule IDNameLevelCategoryDescription
SPEC001SELECT * ProhibitedWARNINGData OperationQuery must specify explicit column list
SPEC002DELETE/UPDATE without WHEREERRORData OperationDML must include WHERE condition
SPEC003Cartesian ProductERRORData OperationMulti-table missing JOIN condition
SPEC004Implicit Type ConversionWARNINGData OperationMay cause unexpected results
SPEC005LIKE Leading WildcardWARNINGData OperationCannot use partition pruning
SPEC006Partition Field FunctionWARNINGData OperationFunction on partition field prevents pruning
SPEC007INSERT Missing Column ListWARNINGData OperationRelies on default column order
SPEC008Missing Table CommentINFOObject DesignTable without comment
SPEC009Reserved Keyword as IdentifierERRORNamingMay cause syntax ambiguity
SPEC010Column Name Too LongWARNINGNamingColumn name exceeds 30 characters
SPEC012FLOAT/DOUBLE for MoneyERRORObject DesignUse DECIMAL for monetary fields
SPEC013Too Many ColumnsWARNINGObject DesignTable should not exceed 100 columns
SPEC014Too Many Partition FieldsWARNINGObject DesignPartition fields should not exceed 3
SPEC015Missing Column CommentINFOObject DesignColumn without comment
SPEC016CASE WHEN Missing ELSEWARNINGData OperationCASE WHEN should include ELSE clause
SPEC017NULL Value HandlingWARNINGData OperationNULL handling in conditions
SPEC018String 'null' ProhibitedERRORData OperationDo not use string 'NULL'
SPEC019JOIN Field Type MismatchWARNINGData OperationJoin fields should have same type
SPEC020INSERT INTO VALUESWARNINGSQL DevUse LOAD DATA or INSERT SELECT instead
SPEC021Subquery Nesting DepthWARNINGSQL DevSubquery should not exceed 3 levels
SPEC022Partition Pruning MissingERRORData OperationPartitioned table query without partition filter
SPEC023Non-Standard Join ConditionWARNINGData OperationJOIN ON should not contain IF/CASE WHEN
SPEC024CASCADE Usage WarningWARNINGSQL DevUse CASCADE carefully in ALTER TABLE
SPEC025Hive on Spark ProhibitedWARNINGSQL DevShould use Hive on Tez

Step 6: Large SQL Interception Check

Detect high-risk SQL that may exhaust cluster resources:

Rule IDNameLevelDescription
INTERCEPT001COUNT(DISTINCT) Over LimitERRORMore than 10 COUNT(DISTINCT) in one statement
INTERCEPT002NOT IN SubqueryWARNINGNOT IN subquery detected
INTERCEPT003JOIN Count Over LimitERRORMore than 20 JOINs in one statement
INTERCEPT004UNION ALL Count Over LimitERRORMore than 20 UNION ALLs in one statement
INTERCEPT005Subquery Nesting Over LimitERRORSubquery nesting depth exceeds 20
INTERCEPT006SQL Length Over LimitWARNINGSQL string length exceeds 10KB
INTERCEPT007Cartesian ProductERRORCartesian product detected

Step 7: Generate Report

Use the check engine to generate a Markdown format report:

bash
python ~/.cac/skills/huawei-cloud-mrs-hive-sql-check/scripts/hive_sql_checker.py "<sql_text>" all

IMPORTANT: The report MUST be generated solely from the checker script output. Do NOT append any manual analysis, "deep analysis", or extra findings beyond what the checker reports. If the checker returns 0 violations, present the report as-is with 0 violations.

Report format:

markdown
# MRS Hive SQL Check Report

**Check Time**: 2026-07-13T10:00:00
**Statement Type**: SELECT
**Check Mode**: all

## Summary

| Metric | Value |
|--------|-------|
| Total Rules | 60 |
| Passed | 55 |
| Violations | 5 |
| Errors (ERROR) | 2 |
| Warnings (WARNING) | 2 |
| 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

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

## Large SQL Interception

### [X] INTERCEPT001: COUNT(DISTINCT) Over Limit
- **Level**: ERROR
- **Description**: SQL contains more than 10 COUNT(DISTINCT) expressions
- **Fix Suggestion**: Split into multiple subqueries using UNION ALL

Core Commands

hive_sql_checker.py hive_sql_parser.py hive_sql_tokenizer.py

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-SYN013)
  • Specification check section: Violations from specification rules (SPEC001-SPEC025)
  • Large SQL interception section: Violations from interception rules (INTERCEPT001-INTERCEPT011)
  • 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-mrs-hive-sql-check/scripts/hive_sql_checker.py "<sql_text>" [syntax|spec|all]

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

python
from hive_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 PARTITIONED BY for large tables
  3. Use ORC storage format for better compression and query performance
  4. Always add partition filter conditions when querying partitioned tables
  5. Use all mode for comprehensive checking

References

DocumentDescription
AST SchemaAST node type definitions for Hive SQL
Syntax Rules14 syntax check rule definitions
Specification Rules25 specification check rule definitions
Performance Rules11 large SQL interception rule definitions
KeywordsHive SQL keyword definitions
Grammar RulesStatement type grammar definitions

Notes

  1. Syntax and specification checks do not require cluster connection, can run offline
  2. Large SQL interception rules are designed to prevent cluster resource exhaustion
  3. Hive-specific syntax checking (PARTITIONED BY, CLUSTERED BY, STORED AS, etc.) is based on HiveQL grammar definitions
  4. The check engine includes a custom tokenizer and recursive descent parser, no external SQL parsing libraries required
  5. STRICT RULE: Only report checker engine output. Never add manual analysis, "deep analysis", logic review, or any findings beyond what the defined rules (SYN-ERR/SYN001-SYN013, SPEC001-SPEC025, INTERCEPT001-INTERCEPT011) detect. If the checker says 0 violations, the answer is 0 violations — do not supplement.

Arquivos incluídos

O modelo lê esses arquivos sob demanda enquanto a habilidade está carregada. Eles são disponibilizados para leitura e nunca são executados.

Perguntas frequentes

O que a habilidade de IA Huawei Cloud Mrs Hive Sql Check faz?

Huawei Cloud MRS Hive SQL specification checking skill. Checks SQL statements against defined syntax and specification rules using the automated checker engine. No extra manual analysis beyond defined rules. Trigger:"Hive SQL优化"、"检查Hive SQL"、"Hive SQL检查"、"Hive SQL规范"、"Hive SQL语法"、"Hive SQL review"

Por que usar Huawei Cloud Mrs Hive Sql Check no TypingMind?

Porque basta instalar uma vez para usar com qualquer modelo. A habilidade Huawei Cloud Mrs Hive Sql Check é escrita em Markdown simples, e não em código específico de um provedor, então a mesma habilidade funciona com GPT-5, Claude, Gemini, Grok ou um modelo local — e é possível trocar de modelo no meio do chat sem que ela deixe de funcionar. No TypingMind, você usa suas próprias chaves de API e paga diretamente aos provedores, em vez de pagar uma assinatura por licença de usuário. Suas habilidades e chats permanecem no seu próprio armazenamento.

Como instalar Huawei Cloud Mrs Hive Sql Check no TypingMind?

Abra Plugins → Habilidades → Instalar do GitHub no TypingMind e cole https://github.com/huaweicloud/huaweicloud-skills/tree/master/skills/bigdata/mrs/huawei-cloud-mrs-hive-sql-check. O TypingMind lê o arquivo SKILL.md, reúne os arquivos da habilidade e a instala para que possa ser ativada em cada chat.

Quais modelos de IA podem usar Huawei Cloud Mrs Hive Sql Check?

Qualquer modelo conectado no TypingMind. As habilidades de IA são instruções em Markdown simples, e não código específico de um provedor. Assim, GPT, Claude, Gemini, Grok e modelos locais podem carregar esta habilidade quando uma solicitação corresponder a ela.

Quantos modelos de IA posso usar com Huawei Cloud Mrs Hive Sql Check?

Quantos quiser. Desde que o modelo ofereça suporte a habilidades, é possível usar Huawei Cloud Mrs Hive Sql Check com ele — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e outros — tudo no TypingMind com suas próprias chaves de API.

A habilidade de IA Huawei Cloud Mrs Hive Sql Check é gratuita?

Sim. A habilidade é publicada no GitHub por huaweicloud sob a licença MIT. O pagamento é feito apenas ao seu provedor de IA pelos tokens usados.

O que são habilidades de IA?

Uma habilidade de IA é um conjunto reutilizável de instruções que ensina um modelo de IA a realizar uma tarefa específica. Ela segue o formato aberto Agent Skills: um arquivo SKILL.md com nome e descrição, além de scripts, templates ou arquivos de referência de que o modelo possa precisar. O modelo lê as instruções apenas quando sua solicitação corresponde à habilidade, então uma habilidade instalada não gera custos até ser usada.

Qual é a diferença entre habilidades de IA e plugins ou servidores MCP?

Um plugin ou servidor MCP oferece ao modelo novas ferramentas que ele pode acionar — código que é executado em algum lugar e retorna um resultado. Já uma habilidade de IA dá ao modelo o conhecimento e as orientações de que ele precisa: como abordar uma tarefa, quais etapas seguir e como deve ser um bom resultado. As habilidades são escritas em Markdown simples, por isso não precisam de servidor, chave de API nem ambiente de execução, e funcionam com qualquer modelo.

Ver lista completa

Crie seu próprio espaço de trabalho com IA agora

Inscreva-se na nossa newsletter para receber avisos sobre novos recursos e futuros sorteios 👇