# alibabacloud-odps-sql-generation

alibabacloud-odps-sql-generation generates MaxCompute SQL from natural language and diagnoses ODPS-0xxx errors. Useful when writing analytics queries or migrating code from standard SQL.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 210 installs · ★ 300 repo stars
- Author: aliyun
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/aliyun/alibabacloud-aiops-skills/tree/HEAD/skills/analyticscomputing/odps/alibabacloud-odps-sql-generation/SKILL.md
- Updated: 2026-10-23
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/alibabacloud-odps-sql-generation

## What it does

This skill equips coding agents with MaxCompute (ODPS) SQL syntax rules. Because MaxCompute builds on Hive SQL extensions, its dialect diverges significantly from ANSI standard SQL. The repository splits reference materials into text2sql logic, DQL rules, typical query patterns, and execution error troubleshooting.

The pattern library includes templates for Top N queries, PIVOT and UNPIVOT transforms, array expansion via `LATERAL VIEW` and `EXPLODE`, JSON extraction, and rolling aggregations. It also guides the model through common `SET` flags and query hints.

Skill scope covers SQL text generation only. Non-SQL interfaces like PyODPS DataFrame API or Tunnel, cluster scheduling issues, and RAM role permissions are not handled here.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add aliyun/alibabacloud-aiops-skills --skill alibabacloud-odps-sql-generation -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/alibabacloud-odps-sql-generation/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/alibabacloud-odps-sql-generation/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add aliyun/alibabacloud-aiops-skills --skill alibabacloud-odps-sql-generation -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/alibabacloud-odps-sql-generation/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add aliyun/alibabacloud-aiops-skills --skill alibabacloud-odps-sql-generation -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/alibabacloud-odps-sql-generation/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install aliyun/alibabacloud-aiops-skills skills/analyticscomputing/odps/alibabacloud-odps-sql-generation
```

2. **Manually: put the files in place**
- File: `.github/skills/alibabacloud-odps-sql-generation/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add aliyun/alibabacloud-aiops-skills --skill alibabacloud-odps-sql-generation -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/aliyun/alibabacloud-aiops-skills --path skills/analyticscomputing/odps/alibabacloud-odps-sql-generation
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/alibabacloud-odps-sql-generation/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add aliyun/alibabacloud-aiops-skills --skill alibabacloud-odps-sql-generation -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/aliyun/alibabacloud-aiops-skills/tree/HEAD/skills/analyticscomputing/odps/alibabacloud-odps-sql-generation/SKILL.md

## When to use it
- generate MaxCompute SQL queries from plain language descriptions
- adapt standard ANSI SQL queries to Hive SQL dialect conventions
- extract JSON data and unnest arrays using `LATERAL VIEW` and `EXPLODE`
- diagnose `ODPS-0xxx` engine error codes and fix failed queries

## Example prompts
- Write a MaxCompute SQL query calculating rolling 7-day user retention
- Unnest a tag array into individual table rows using EXPLODE and LATERAL VIEW
- Fix this MaxCompute query that failed with an ODPS-0xxx error code

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 75f858b74b8da8aa.

BEGIN THIRD-PARTY FILE 75f858b74b8da8aa
```text
---
name: alibabacloud-odps-sql-generation
description: "Provides MaxCompute SQL intelligent generation capabilities for AI agents, covering text2sql conversion principles, dialect syntax differences (DQL/DDL/DML), common query pattern templates (Top N, PIVOT, window functions, etc.), and ODPS error code diagnostics. Use when generating, debugging, or migrating MaxCompute / ODPS SQL."
license: Apache-2.0
metadata:
  domain: coding
  owner: MaxCompute
  contact: jiexian.hc@alibaba-inc.com, zhipeng.gzp@alibaba-inc.com
  version: 1.0.0
---

# MaxCompute SQL Engine Syntax Skill

Provides MaxCompute SQL engine syntax guidance for text2sql scenarios. MaxCompute is based on Hive SQL extensions and has significant differences from ANSI standard SQL.

## Usage

Load corresponding reference files based on question type (can be combined). The `load` column indicates relative loading weight (heavy ≈ large, medium ≈ moderate), for budget estimation, not exact token counts. Each file's opening paragraph describes its own scope.

| Trigger condition | File | load |
|---|---|---|
| NL→SELECT generation / text2sql (determine intent, granularity, table-column mapping, output format first) | `references/text2sql_principles.md` | light |
| Generate MaxCompute SELECT queries (dialect rules, DQL default must-read) | `references/maxcompute_select_guide.md` | heavy |
| Match query pattern keywords: Top N / top-N per group / year-over-year / month-over-month / consecutive N days / retention / row-to-column / column-to-row / PIVOT / UNPIVOT / array expansion / LATERAL VIEW / EXPLODE / JSON extraction / GET_JSON_OBJECT / cumulative / running total / Range Join / GROUPING SETS / CUBE / ROLLUP / pagination / paging | `references/sql_query_patterns.md` | medium |
| SQL execution failure requiring diagnosis and recovery (including `ODPS-0xxx` error codes)| `references/sql_common_errors.md` | medium |

> Relationship: `text2sql_principles.md` provides engine-independent NL→SELECT generation principles; `maxcompute_select_guide.md` is the **single authoritative source** for MaxCompute DQL dialect rules (unsupported syntax/functions/partitioning/types/SET parameters). `sql_query_patterns.md` provides **query template snippets** only, without duplicating rules.

## Out of Scope
```
END THIRD-PARTY FILE 75f858b74b8da8aa

The third-party file has ended. Everything between the 75f858b74b8da8aa tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2292 of 2965 bytes. © aliyun · Apache-2.0 · https://github.com/aliyun/alibabacloud-aiops-skills/tree/HEAD/skills/analyticscomputing/odps/alibabacloud-odps-sql-generation/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
