Logo van Huawei Cloud Doris Sql Check

Huawei Cloud Doris Sql Check

Organisatie
huaweicloud
huawei-cloud-doris-sql-check

Comprehensive SQL statement checking for Apache Doris (based on Doris 3.1.4 Nereids ANTLR4 grammar), supporting two check modes: 1. Syntax Check - Keyword validation, statement structure verification, clause completeness, Doris-specific syntax compatibility (DISTRIBUTED BY, PARTITION BY, ENGINE, DUPLICATE/AGGREGATE/UNIQUE KEY, INSERT OVERWRITE, LOAD, EXPORT, MTMV, BACKUP/RESTORE etc.) 2. Specification Check - Object design standards, data operation standards, naming conventions based on Apache Doris development best practices. Built-in custom Doris SQL tokenizer (504 keywords from DorisLexer.g4) and recursive descent parser supporting 100+ Doris statement types. Applicable when users need SQL quality review, syntax validation, or specification compliance checking for Apache Doris SQL (versions 2.1.x / 3.0.x / 3.1.x / 4.x). 触发词:"Doris SQL检查"、"Doris SQL规范"、"Doris SQL审计"、"Doris SQL语法"、"检查Doris SQL"、"Doris SQL review"

Overzicht

Uitgeverhuaweicloud
Repositoryhuaweicloud-skills
Skillnaamhuawei-cloud-doris-sql-check
Sterren
59
Forks
24
Meegeleverde bestanden
10
LicentieMIT
Links
  • Instructies in Markdown

    Het model laadt het bestand SKILL.md alleen als dat nodig is. Dat kost dus alleen tokens als een verzoek daadwerkelijk bij de skill past.

  • Werkt met elk LLM

    AI-skills bestaan uit instructies in gewone Markdown, niet uit aanbiederspecifieke code. Daardoor werken ze met GPT, Claude, Gemini, Grok of een lokaal model.

  • Meegeleverde bestanden: 10

    Scripts, sjablonen en referentiemateriaal die het model tijdens het werken kan lezen. De bestanden kunnen alleen worden gelezen en worden nooit uitgevoerd.

  • Open source

    Gepubliceerd door huaweicloud op GitHub. Bekijk de bronbestanden voordat je de skill installeert.

Installatie

Installeer de AI-skill Huawei Cloud Doris Sql Check in TypingMind om deze met elk LLM te gebruiken, of voeg de skill toe aan een andere agent die SKILL.md kan lezen.

1

Installeren in TypingMind

TypingMind installeert een skill rechtstreeks vanuit de GitHub-map. De app leest SKILL.md, bundelt de bijbehorende bestanden en slaat het resultaat lokaal op.

  1. Open de app en ga naar Plug-ins → Skills.
  2. Kies "Installeren via GitHub".
  3. Plak de onderstaande URL van de skillmap en bevestig.
    https://github.com/huaweicloud/huaweicloud-skills/tree/master/skills/bigdata/mrs/huawei-cloud-doris-sql-check
  4. Schakel de skill in voor elke chat waarin je de skill wilt kunnen gebruiken.
Plug-ins → Skills → Skill toevoegen → Via GitHub-URL. Plak vervolgens de map-URL en druk op Doorgaan.
2

Installeren in een andere agent

Elke agent die het Agent Skills-formaat kan lezen, kan deze skill gebruiken — kopieer de map naar de skillmap van die agent.

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-doris-sql-check .claude/skills/huawei-cloud-doris-sql-check
Start Claude Code na het kopiëren opnieuw op, zodat de nieuwe skill wordt herkend.

Gebruik deze skill in TypingMind

Schakel Huawei Cloud Doris Sql Check in voor een chat naar keuze in TypingMind en het model doet de rest. De naam en beschrijving staan in de systeemprompt. Zodra een verzoek bij de skill past, laadt het model zelf de volledige instructies. Je hoeft de skill nooit handmatig aan te roepen. Pas als het model de skill daadwerkelijk gebruikt, kost dat tokens.

Het model laadt Huawei Cloud Doris Sql Check automatisch zodra een verzoek erbij past.

Werkt met elk AI-model

AI-skills zijn gewone Markdown-instructies in plaats van aanbiederspecifieke code. Daardoor is Huawei Cloud Doris Sql Check niet gebonden aan het model waarvoor de skill is geschreven. Installeer de skill één keer in TypingMind en gebruik deze met GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama of een lokaal model dat je zelf draait — allemaal met je eigen API-sleutels.

  • Alleen geladen wanneer nodig

    De systeemprompt bevat alleen de naam en beschrijving. De instructies worden bij het eerste bijpassende verzoek opgehaald, dus een ongebruikte skill kost niets.

  • Wissel van model tijdens een chat

    Omdat de skill uit instructies bestaat en niet uit code, blijft deze werken als je van model wisselt — het volgende model leest hetzelfde SKILL.md-bestand.

Skillinstructies

Dit is de inhoud van SKILL.md die het model laadt. Lees deze vóór de installatie — een skill bestaat uit instructies die je model zal volgen.

Doris SQL Check Skill

You are an Apache Doris SQL specification checking expert, responsible for comprehensive SQL statement checking for Apache Doris (based on Doris 3.1.4 source code). You have a custom-built Doris SQL tokenizer and recursive descent parser that can precisely identify Doris-specific syntax from the Nereids ANTLR4 grammar (DorisLexer.g4 / DorisParser.g4).

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 a Doris cluster (FE/BE)
  • Review SQL statements against Apache Doris development best practices
  • Check Doris-specific syntax (DISTRIBUTED BY HASH/RANDOM, PARTITION BY RANGE/LIST/AUTO, BUCKETS, PROPERTIES, ENGINE, DUPLICATE/AGGREGATE/UNIQUE KEY, INSERT OVERWRITE TABLE, LOAD LABEL, ROUTINE LOAD, EXPORT, MTMV, BACKUP/RESTORE SNAPSHOT, ADMIN SET/SHOW, CANCEL, KILL, TABLESAMPLE, OUTFILE, Hint /*+ /, full-text MATCH_, COLOCATE GROUP)
  • Identify potential performance anti-patterns in Doris SQL statements

Typical Use Cases:

  • "Check this Doris SQL: SELECT * FROM t1"
  • "Does this CREATE TABLE follow Doris specification (DISTRIBUTED BY, KEY model, PARTITION)?"
  • "Validate the syntax of this INSERT OVERWRITE TABLE statement"
  • "Review my Doris SQL for specification compliance"
  • "Check if my SQL uses Doris-specific syntax correctly (MTMV, LOAD, EXPORT)"
  • "Validate BACKUP/RESTORE SNAPSHOT syntax"
  • "Check my ROUTINE LOAD job definition"

Check Modes

ModeDependencyDescription
syntaxNoneSyntax check: keyword validity, statement structure, clause completeness, Doris 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-doris-sql-check/scripts/doris_sql_tokenizer.py "<sql_text>"

The tokenizer supports:

  • All 504 Doris keywords (from DorisLexer.g4 between --DORIS-KEYWORD-LIST-START and --DORIS-KEYWORD-LIST-END)
  • Doris-specific tokens: HINT (/*+ ... */), BACKQUOTED (`ident`), ARROW (->), NSEQ (<=> null-safe eq), EQ (= or ==), NEQ (<> or !=), LTE (<= or !>), GTE (>= or !<), DOUBLEPIPES (||), LOGICALAND (&&), LOGICALNOT (!)
  • Literals: strings ('...' / "..."), integers, decimals, bigints (123L), smallints (123S), tinyints (123Y), bigdecimals (123BD), exponents
  • Backquoted identifiers: `table_name` (Doris-style, preferred over double quotes)
  • Comment skipping (-- single line, /* */ multi-line, but /*+ hint */ preserved as HINT token)
  • Full-text search operators: MATCH_ALL, MATCH_ANY, MATCH_PHRASE, MATCH_PHRASE_PREFIX, MATCH_PHRASE_EDGE, MATCH_REGEXP, MATCH_NAME, MATCH_NAME_GLOB

Step 3: Parsing

Run the parser to generate AST and detect syntax errors.

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

The parser supports major Doris statement types (based on DorisParser.g4):

  • DML: SELECT (with CTE, set ops, window, TABLESAMPLE), INSERT INTO/OVERWRITE TABLE, UPDATE, DELETE, LOAD (BROKER LOAD), EXPORT, COPY INTO, TRUNCATE
  • DDL: CREATE TABLE (with DISTRIBUTED BY, PARTITION BY, KEY model, ENGINE, PROPERTIES), CREATE TABLE LIKE, CREATE VIEW, CREATE MTMV (Multi-Table Materialized View), CREATE INDEX (BITMAP/NGRAM_BF/INVERTED), ALTER TABLE (ADD/MODIFY/DROP/RENAME COLUMN, ADD/DROP PARTITION, ADD/DROP INDEX, ROLLUP, TAG/BRANCH), DROP TABLE/VIEW/INDEX, CREATE CATALOG, CREATE DATABASE, CREATE USER/ROLE, CREATE RESOURCE, CREATE STAGE, CREATE ENCRYPTKEY, CREATE JOB, CREATE ROW POLICY, CREATE SQL_BLOCK_RULE, CREATE STORAGE VAULT/POLICY, CREATE WORKLOAD GROUP/POLICY
  • DCL: GRANT/REVOKE (table/resource/role privileges)
  • TCL: BEGIN/START TRANSACTION, COMMIT, ROLLBACK
  • Utility: EXPLAIN (PARSED/ANALYZED/REWRITTEN/LOGICAL/OPTIMIZED/PHYSICAL/SHAPE/MEMO/DISTRIBUTED/ALL, VERBOSE/TREE/GRAPH/PLAN), SET (variables/options), SHOW (50+ variants), DESC/DESCRIBE, ADMIN SET/SHOW (replica, frontend config, tablet diagnose, trash, TDE), KILL (CONNECTION/QUERY), CANCEL (LOAD/EXPORT/ALTER TABLE/BACKUP/RESTORE/WARM UP), BACKUP/RESTORE SNAPSHOT, RECOVER (DATABASE/TABLE/PARTITION), CLEAN (LABEL/PROFILE/QUERY STATS), INSTALL/UNINSTALL PLUGIN, LOCK/UNLOCK TABLES, WARM UP, SYNC, HELP, CALL PROCEDURE

Doris-specific syntax:

  • DISTRIBUTED BY {HASH(cols) | RANDOM} (BUCKETS n | AUTO)?
  • PARTITION BY (RANGE | LIST)? ... (AUTO)? (auto partition, step partition, less-than, fixed, in-list)
  • (DUPLICATE | AGGREGATE | UNIQUE) KEY (cols) (CLUSTER BY cols)?
  • ENGINE = olap | mysql | elasticsearch | hive | hudi | iceberg | jdbc | ...
  • PROPERTIES ('key'='value', ...)
  • INSERT OVERWRITE TABLE ...
  • LOAD LABEL ... (DATA INFILE (...) INTO TABLE ...)
  • CREATE ROUTINE LOAD ... FROM type (...)
  • EXPORT TABLE ... TO ...
  • BACKUP SNAPSHOT ... TO repo (ON|EXCLUDE (...))?
  • RESTORE SNAPSHOT ... FROM repo (ON|EXCLUDE (...))?
  • EXPLAIN {PARSED|ANALYZED|REWRITTEN|LOGICAL|OPTIMIZED|PHYSICAL|SHAPE|MEMO|DISTRIBUTED|ALL} [VERBOSE|TREE|GRAPH|PLAN] [PROCESS]
  • CREATE MATERIALIZED VIEW ... (DUPLICATE KEY ...)? PARTITION BY ... DISTRIBUTED BY ... AS query
    • BUILD [IMMEDIATE|DEFERRED], REFRESH [COMPLETE|AUTO], ON [MANUAL|SCHEDULE|COMMIT]
  • TABLESAMPLE (...) (REPEATABLE n)?
  • WITH cte_name AS (...) (CTE; Doris does not require explicit RECURSIVE keyword)
  • Window functions: OVER (PARTITION BY ... ORDER BY ... ROWS/RANGE ...)
  • OUTFILE 'path' (FORMAT AS ...)? (PROPERTIES (...))?
  • Hints: /*+ hint_name(...) */ and [hint_name] relation hints
  • ALTER COLOCATE GROUP name SET (...)
  • Full-text search: col MATCH_ALL '...', MATCH_PHRASE, MATCH_PHRASE_PREFIX, MATCH_PHRASE_EDGE, MATCH_ANY, MATCH_REGEXP
  • Aggregate unions: HLL_UNION, BITMAP_UNION, QUANTILE_UNION, REPLACE_IF_NOT_NULL
  • Doris data types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, BOOLEAN, FLOAT, DOUBLE, DATE, DATETIME, DATEV2, DATETIMEV2, DATEV1, DATETIMEV1, BITMAP, QUANTILE_STATE, HLL, AGG_STATE, STRING, JSON, JSONB, TEXT, VARCHAR, CHAR, DECIMAL, DECIMALV2, DECIMALV3, IPV4, IPV6, ARRAY, MAP, STRUCT, VARIANT

Step 4: Syntax Check

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

Syntax Check Rules (34 rules):

Rule IDNameLevelDescription
SYN-ERRLexical ErrorERRORUnrecognized characters in SQL text
SYN001Invalid KeywordERRORKeyword not supported by Doris (not in 504-keyword list)
SYN002Reserved Keyword as IdentifierERRORReserved keyword used as identifier without backticks
SYN003Syntax Structure ErrorERRORMissing required clause or keyword
SYN004Clause Ordering ErrorERRORSQL clause order does not conform to grammar
SYN005DISTRIBUTED BY Syntax ErrorERRORInvalid distribution strategy (only HASH/RANDOM supported)
SYN006PARTITION BY Syntax ErrorERRORInvalid partition definition (RANGE/LIST/AUTO)
SYN007BUCKETS Syntax ErrorERRORInvalid BUCKETS clause (must be INTEGER or AUTO)
SYN008EXPLAIN planType Syntax ErrorERRORInvalid EXPLAIN plan type (PARSED/ANALYZED/REWRITTEN/LOGICAL/OPTIMIZED/PHYSICAL/SHAPE/MEMO/DISTRIBUTED/ALL)
SYN009KEY Model Syntax ErrorERRORInvalid data model (DUPLICATE/AGGREGATE/UNIQUE KEY)
SYN010PROPERTIES Syntax ErrorERRORInvalid PROPERTIES clause structure
SYN011ENGINE Syntax ErrorERRORInvalid ENGINE clause
SYN012INSERT OVERWRITE Syntax ErrorERRORInvalid INSERT OVERWRITE TABLE structure
SYN013LOAD Syntax ErrorERRORInvalid LOAD LABEL / BROKER LOAD structure
SYN014ROUTINE LOAD Syntax ErrorERRORInvalid CREATE ROUTINE LOAD structure
SYN015EXPORT Syntax ErrorERRORInvalid EXPORT TABLE ... TO structure
SYN016BACKUP/RESTORE SNAPSHOT Syntax ErrorERRORInvalid BACKUP/RESTORE SNAPSHOT structure
SYN017CREATE MTMV Syntax ErrorERRORInvalid CREATE MATERIALIZED VIEW structure
SYN018CREATE CATALOG Syntax ErrorERRORInvalid CREATE CATALOG structure
SYN019CREATE USER/ROLE Syntax ErrorERRORInvalid CREATE USER/ROLE structure
SYN020CREATE ROW POLICY Syntax ErrorERRORInvalid CREATE ROW POLICY structure
SYN021CREATE SQL_BLOCK_RULE Syntax ErrorERRORInvalid CREATE SQL_BLOCK_RULE structure
SYN022CREATE STAGE Syntax ErrorERRORInvalid CREATE STAGE structure
SYN023CREATE JOB Syntax ErrorERRORInvalid CREATE JOB ON SCHEDULE structure
SYN024CREATE ENCRYPTKEY Syntax ErrorERRORInvalid CREATE ENCRYPTKEY structure
SYN025ADMIN SET/SHOW Syntax ErrorERRORInvalid ADMIN statement structure
SYN026CANCEL Syntax ErrorERRORInvalid CANCEL statement (LOAD/EXPORT/ALTER/BACKUP/RESTORE/WARM UP)
SYN027KILL Syntax ErrorERRORInvalid KILL (CONNECTION/QUERY) statement
SYN028TABLESAMPLE Syntax ErrorERRORInvalid TABLESAMPLE clause (PERCENT/ROWS, REPEATABLE)
SYN029OUTFILE Syntax ErrorERRORInvalid OUTFILE clause (FORMAT AS, PROPERTIES)
SYN030Hint Syntax ErrorWARNINGInvalid hint format (must be /*+ name(...) */ or [name])
SYN031Full-text MATCH Syntax ErrorERRORInvalid MATCH_ALL/MATCH_ANY/MATCH_PHRASE/MATCH_REGEXP usage
SYN032COLOCATE GROUP Syntax ErrorERRORInvalid ALTER COLOCATE GROUP structure
SYN033GRANT/REVOKE Syntax ErrorERRORInvalid GRANT/REVOKE privilege structure

Step 5: Specification Check

Based on AST and Token stream, execute specification check rules. Rules are derived from DorisParser.g4 grammar definitions and Apache Doris development best practices.

Specification Check Rules (46 rules):

Rule IDNameLevelCategoryDescription
SPEC001Missing DISTRIBUTED BYERRORObject DesignCREATE TABLE without distribution strategy (Doris requires DISTRIBUTED BY HASH or RANDOM)
SPEC002Missing ENGINEINFOObject DesignCREATE TABLE without explicit ENGINE (defaults to OLAP)
SPEC003SELECT * ProhibitedERRORData OperationQuery must specify explicit column list
SPEC004DELETE/UPDATE without WHEREERRORData OperationDML must include WHERE condition
SPEC005NOT IN SubqueryWARNINGData OperationRecommend NOT EXISTS or LEFT JOIN ... IS NULL
SPEC006DISTINCT PerformanceINFOData OperationDISTINCT may impact performance
SPEC007Implicit Type ConversionWARNINGData OperationMay cause index/zone-map invalidation
SPEC008LIKE Leading WildcardWARNINGData OperationCannot use zone-map or index
SPEC009OR ConditionINFOData OperationMay impact execution plan
SPEC010IN List Too LongWARNINGData Operation>1000 values recommend temp table
SPEC011FROM SubqueryINFOData OperationRecommend CTE instead
SPEC012Cartesian ProductERRORData OperationMulti-table missing JOIN condition
SPEC013INSERT Missing Column ListWARNINGData OperationRelies on default column order
SPEC014Missing Table CommentINFOObject DesignTable without COMMENT
SPEC015Table Naming ConventionWARNINGNamingShould use lowercase with underscores
SPEC016Column Naming ConventionWARNINGNamingShould use lowercase with underscores
SPEC017Reserved Keyword as IdentifierERRORNamingMay cause syntax ambiguity
SPEC018Distribution Key Column Not FoundWARNINGObject DesignDistribution key should be actual table column
SPEC019Partition Key Same as Distribution KeyINFOObject DesignMay cause data skew
SPEC020Missing KEY Model DefinitionINFOObject DesignRecommend explicit DUPLICATE/AGGREGATE/UNIQUE KEY
SPEC021Large Table Should Have PartitionINFOObject DesignImprove query and governance efficiency
SPEC022BUCKETS Count RecommendationINFOObject DesignRecommend appropriate bucket count for table size
SPEC023Column Should Have NOT NULLINFOObject DesignOptimizer can leverage NOT NULL
SPEC024DROP Should Use IF EXISTSWARNINGSQL DevPrevent error when object not found
SPEC025INSERT Multi-VALUESWARNINGSQL DevMultiple VALUES groups inefficient; use STREAM LOAD / BROKER LOAD
SPEC026Column-store Real-time INSERTWARNINGSQL DevFrequent small-batch INSERT into Doris (columnar) causes compaction pressure
SPEC027Frequent UPDATE/DELETEWARNINGSQL DevDoris UPDATE/DELETE is costly (read-merge-write)
SPEC028Function on Filter ColumnWARNINGSQL DevAffects statistics accuracy and zone-map usage
SPEC029Large Table COUNTWARNINGSQL DevFull table scan I/O cost
SPEC030Query Should Use LIMITINFOSQL DevAvoid oversized result sets
SPEC031CTE Recursion SafetyWARNINGSQL DevEnsure termination condition for recursive CTE
SPEC032Use Catalog/DB PrefixINFOSQL DevAvoid ambiguity in multi-catalog scenarios
SPEC033View Nesting Depth ≤ 3INFOObject DesignRequires cluster: query view dependencies
SPEC034Index Count > 5WARNINGObject DesignRequires cluster: query table indexes
SPEC035Non-pushdown SQL ProhibitedERRORSQL DevRequires cluster: EXPLAIN analysis
SPEC036BITMAP/HLL Column Needs Aggregation TypeWARNINGObject DesignBITMAP/HLL columns should specify BITMAP_UNION/HLL_UNION
SPEC037Use MTMV for Repeated Complex QueriesINFOObject DesignRecommend MTMV for repeated aggregation queries
SPEC038Avoid Frequent OUTFILE ExportINFOSQL DevUse EXPORT or broker for large exports
SPEC039VARCHAR Length Should Be ExplicitWARNINGObject DesignAvoid VARCHAR without length for large strings
SPEC040DECIMAL Precision Should Be ExplicitWARNINGObject DesignUse DECIMAL(p,s) or DECIMALV3(p,s), avoid bare DECIMAL
SPEC041COUNT(DISTINCT) Excessive UseERRORComplex Query LimitCOUNT(DISTINCT) count > 5, may cause severe performance degradation
SPEC042NOT IN Subquery ProhibitedERRORComplex Query LimitNOT IN subquery causes full scan and severe performance drop; use NOT EXISTS or LEFT JOIN
SPEC043Excessive JOINsERRORComplex Query LimitJOIN count > 20, may cause unstable query plans and high memory usage
SPEC044Excessive UNION ALLsERRORComplex Query LimitUNION ALL count > 20, may cause complex plans and high resource consumption
SPEC045Deeply Nested SubqueriesERRORComplex Query LimitSubquery nesting depth > 20, may cause severe parse and execution performance issues
SPEC046SQL Statement Too LongERRORComplex Query LimitSQL text length > 2MB, may cause parse timeout or excessive memory usage

Step 6: Generate Report

Use the check engine to generate a Markdown format report:

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

Report format:

markdown
# Doris SQL Check Report

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

## Summary

| Metric | Value |
|--------|-------|
| Total Rules | 74 |
| Passed | 71 |
| 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

Core Commands

doris_sql_checker.py doris_sql_parser.py doris_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-SYN033)
  • 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-doris-sql-check/scripts/doris_sql_checker.py "<sql_text>" [syntax|spec|all]

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

python
from doris_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 DISTRIBUTED BY HASH(分布键) or DISTRIBUTED BY RANDOM to avoid SPEC001
  3. For Doris tables, explicitly specify the KEY model (DUPLICATE KEY/AGGREGATE KEY/UNIQUE KEY)
  4. Use all mode for comprehensive checking
  5. Rules marked with requires_mcp: true or "Requires cluster" (SPEC033, SPEC034, SPEC035) need cluster connection and are skipped in static mode
  6. Doris does NOT support MERGE INTO ... WHEN MATCHED or ON DUPLICATE KEY UPDATE — these will be flagged as syntax errors
  7. Doris identifiers use backticks (`), not double quotes — using double quotes for identifiers will trigger a warning
  8. For large data loading, prefer STREAM LOAD / BROKER LOAD / ROUTINE LOAD over multi-row INSERT VALUES (SPEC025)

References

DocumentDescription
AST SchemaAST node type definitions for Doris SQL
Syntax Rules34 syntax check rule definitions
Specification Rules40 specification check rule definitions
Performance Rules11 performance check rule definitions (requires cluster)
Keywords504 Doris SQL keyword definitions (from DorisLexer.g4)
Grammar Rules100+ Doris statement type grammar definitions (from DorisParser.g4)

Notes

  1. Syntax and specification checks do not require cluster connection, can run offline
  2. Rules marked "Requires cluster" (SPEC033, SPEC034, SPEC035) are skipped in static mode
  3. Performance rules (PERF001-PERF011) are defined in rules/perf_rules.yaml but require cluster connection for execution (EXPLAIN ANALYZE, system tables like information_schema.tables, backends, etc.)
  4. Doris-specific syntax checking (DISTRIBUTED BY, PARTITION BY, BUCKETS, PROPERTIES, ENGINE, DUPLICATE/AGGREGATE/UNIQUE KEY, INSERT OVERWRITE, LOAD, EXPORT, MTMV, BACKUP/RESTORE, ADMIN, CANCEL, KILL, TABLESAMPLE, OUTFILE, Hint, MATCH, COLOCATE GROUP) is based on DorisParser.g4 (Nereids ANTLR4 grammar) from Doris 3.1.4 source
  5. The check engine includes a custom tokenizer and recursive descent parser, no external SQL parsing libraries required (no ANTLR runtime needed)
  6. Version compatibility: This skill is based on Doris 3.1.4 grammar. Doris 2.1.x / 3.0.x / 3.1.x / 4.x share the same Nereids grammar for most constructs; minor differences may exist for newer syntax (e.g., 4.x added features). Verify against your cluster's version before relying on specific rules.

Meegeleverde bestanden

Zolang de skill geladen is, leest het model deze bestanden als dat nodig is. Het model kan ze alleen lezen; ze worden nooit uitgevoerd.

Veelgestelde vragen

Wat doet de AI-skill Huawei Cloud Doris Sql Check?

Comprehensive SQL statement checking for Apache Doris (based on Doris 3.1.4 Nereids ANTLR4 grammar), supporting two check modes: 1. Syntax Check - Keyword validation, statement structure verification, clause completeness, Doris-specific syntax compatibility (DISTRIBUTED BY, PARTITION BY, ENGINE, DUPLICATE/AGGREGATE/UNIQUE KEY, INSERT OVERWRITE, LOAD, EXPORT, MTMV, BACKUP/RESTORE etc.) 2. Specification Check - Object design standards, data operation standards, naming conventions based on Apache Doris development best practices. Built-in custom Doris SQL tokenizer (504 keywords from DorisLexe...

Waarom Huawei Cloud Doris Sql Check gebruiken in TypingMind?

Omdat je deze skill één keer installeert en met elk model kunt gebruiken. Huawei Cloud Doris Sql Check bestaat uit gewone Markdown in plaats van aanbiederspecifieke code. Dezelfde skill werkt dus met GPT-5, Claude, Gemini, Grok of een lokaal model. Ook als je midden in een chat van model wisselt, blijft de skill werken. TypingMind werkt met je eigen API-sleutels, dus je betaalt aanbieders rechtstreeks in plaats van een abonnement per gebruikersplek af te sluiten. Je skills en chats blijven in je eigen opslag.

Hoe installeer ik Huawei Cloud Doris Sql Check in TypingMind?

Open Plug-ins → Skills → Installeren vanaf GitHub in TypingMind en plak https://github.com/huaweicloud/huaweicloud-skills/tree/master/skills/bigdata/mrs/huawei-cloud-doris-sql-check. TypingMind leest het bestand SKILL.md, bundelt de bijbehorende bestanden en installeert het geheel als een skill die je per chat kunt inschakelen.

Welke AI-modellen kunnen Huawei Cloud Doris Sql Check gebruiken?

Elk model dat je in TypingMind koppelt. AI-skills bestaan uit gewone Markdown-instructies in plaats van aanbiederspecifieke code. GPT, Claude, Gemini, Grok en lokale modellen kunnen deze skill dus allemaal laden wanneer een verzoek erbij past.

Hoeveel AI-modellen kan ik met Huawei Cloud Doris Sql Check gebruiken?

Zoveel als je wilt. Je kunt Huawei Cloud Doris Sql Check gebruiken met elk model dat skills ondersteunt, zoals GPT, Claude, Gemini, Grok, DeepSeek, Mistral of Llama. Allemaal in TypingMind met je eigen API-sleutels.

Is de AI-skill Huawei Cloud Doris Sql Check gratis?

Ja. Deze skill is door huaweicloud op GitHub gepubliceerd onder de licentie MIT. Je betaalt alleen je eigen AI-aanbieder voor de tokens die je gebruikt.

Wat zijn AI-skills?

Een AI-skill is een herbruikbare bundel instructies die een AI-model leert hoe het één specifieke taak moet uitvoeren. De skill volgt het open Agent Skills-formaat: het bestand SKILL.md bevat de naam en beschrijving van de skill. Daarnaast kan de skill scripts, sjablonen of referentiebestanden bevatten die het model nodig heeft. Het model leest de instructies alleen als je verzoek bij de skill past. Een geïnstalleerde skill kost dus niets zolang deze niet wordt gebruikt.

Waarin verschillen AI-skills van plug-ins of MCP-servers?

Een plug-in of MCP-server geeft een model nieuwe tools om aan te roepen: code die ergens wordt uitgevoerd en een resultaat teruggeeft. Een AI-skill geeft het model juist kennis en een werkwijze: hoe het een taak moet aanpakken, welke stappen het moet volgen en hoe goede uitvoer eruitziet. Skills bestaan uit gewone Markdown en hebben dus geen server, API-sleutel of runtime nodig. Ze werken met elk model.

Bekijk alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇