Install
openclaw skills install @sdk-team/alibabacloud-analyticdb-mysql-serverless-analysisAnalyze OSS data through an Alibaba Cloud AnalyticDB for MySQL (ADB) Serverless workspace with read-only, bounded Presto SQL. Trigger only when the user explicitly mentions ADB or AnalyticDB MySQL, provides a workspaceId and an oss:// path, and asks to discover, query, or analyze data. Do not trigger for an OSS path, token, accessToken, workspace, or generic SQL question alone. After triggering, validate endpoint or regionCode, workspaceId, an explicit accessToken or ADB_ACCESS_TOKEN, OSS URI, and the analysis goal together, then choose registered Hive metadata, files(...), or hive_files(...).
openclaw skills install @sdk-team/alibabacloud-analyticdb-mysql-serverless-analysisHelp the user discover and analyze a selected OSS path through the ADB Serverless Query API:
SELECT, SHOW, DESCRIBE, or DESC.accessToken explicitly supplied by the user for the current request before falling back to ADB_ACCESS_TOKEN. The explicit value overrides the environment value without persistently changing it.parquet_file(...), csv_file(...), or json_file(...) readers. Use the format-inferencing files(...) entry point for unregistered data, or hive_files(...) only for a confirmed Hive partition layout.files(...) or hive_files(...) merely because the OSS URI contains a table-prefix. Discover registered Hive metadata first unless the user explicitly confirms that the exact prefix has no registered table. The bundled client rejects format-specific readers, non-aggregate direct-file SELECT statements without LIMIT, and direct-file aggregates without a WHERE scope before any network request.outputs/, ran_scripts/, reproduced command files, or audit logs merely for evaluator bookkeeping.scripts/adb_query.py.argparse, collections.abc, json, os, re, sys, typing, and urllib. It has no third-party package or pip dependency, so no requirements.txt is needed.| Parameter | Requirement | Validation |
|---|---|---|
endpoint or regionCode | Exactly one | The endpoint must be an HTTPS service root with no credentials, query, or fragment. A regionCode derives https://serverless.{regionCode}.ads.aliyuncs.com. |
workspaceId | Required | Must look like ws-... and must come from the user. |
accessToken or ADB_ACCESS_TOKEN | Required for a live request | Prefer a non-empty accessToken explicitly supplied for this request. Otherwise, check only whether ADB_ACCESS_TOKEN exists. Never print either value. |
ossUri | Required | Must start with oss://, include a bucket, and identify a clear scan scope. |
analysisGoal | Required | Must identify the question, metric, dimension, filter, or time range to analyze. |
If any input is missing, report every missing item in one response and stop before network access. If neither credential source is available, tell the user to configure ADB_ACCESS_TOKEN outside the conversation. Never ask the user to paste a token into chat, but accept one they voluntarily supplied and use it only for the current request.
When the user corrects a parameter, the most recent explicit correction replaces the earlier value for the current request. Revalidate the complete parameter set and use only the corrected endpoint or regionCode, workspaceId, OSS URI, and goal in dry-run and live requests. Never send a request with a superseded value merely to prove that it is wrong.
After validation, keep the confirmed endpoint or regionCode, workspaceId, and OSS URI as an immutable parameter ledger for the current request. Copy those exact literals into every command; do not retype, normalize, abbreviate, or reconstruct them from memory. Before every invocation, compare the command arguments and SQL scope with the ledger character-for-character. Treat any mismatch as a local command-construction error: do not send a live request, rebuild the command from the confirmed literals, and run dry-run again.
When a later user message supplies the table-prefix that was missing from a bucket-root request, combine that prefix with the previously confirmed bucket, revalidate the complete current parameter set, and continue from source selection without asking again for values that remain explicit and valid. When a later message explicitly confirms an exact large-scan SQL plan, use this rigid sequence: dry-run SHOW SCHEMAS; live SHOW SCHEMAS; SHOW TABLES; successful DESCRIBE; then the exact confirmed SQL. Do not prepend, interleave, or append a direct-file query, sample, alternate aggregate, or artifact action. Execute only that confirmed SQL after the required metadata checks; do not repeat the confirmation question or broaden the plan. Resolve scripts/adb_query.py from the absolute base directory printed when this skill loads; do not guess a task-working-directory-relative path.
When no explicit accessToken was supplied, check environment-token presence only with a command that cannot print its value:
test -n "${ADB_ACCESS_TOKEN:-}"
Upon loading this skill, generate a random session ID (32-char lowercase hex string) once for the entire session. Use python3 -c 'import secrets; print(secrets.token_hex(16))' so the length is exact, then reuse that value as {session-id} below.
Rule: Every aliyun CLI command that calls a cloud API MUST include the --user-agent flag.
Local utility commands (e.g. configure, plugin, version) do not support this flag and should be excluded.
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-mysql-serverless-analysis/{session-id}
Example (assuming session-id is a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6):
aliyun ecs describe-instances --biz-region-id cn-hangzhou --user-agent AlibabaCloud-Agent-Skills/alibabacloud-analyticdb-mysql-serverless-analysis/a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6
Do not skip, alter the format, or omit --user-agent on any aliyun API command invocation.
Script / Terraform execution: When running Python SDK scripts or Terraform commands or bash scripts, inject the session-id via inline environment variable so the code can read it at runtime:
# Python SDK script
SKILL_SESSION_ID={session-id} python3 scripts/deploy.py
# Terraform
SKILL_SESSION_ID={session-id} terraform apply
Scripts and Terraform configs should read SKILL_SESSION_ID from the environment (default to empty string if absent). See references/how-to-implement-by-common-sdk.md for SDK patterns.
accessToken first, otherwise ADB_ACCESS_TOKEN. Do not compare, log, or display the values.--dry-run before the first live request to validate the URL, workspaceId, and SQL request body. A dry-run is a parameter-fidelity gate, not just a syntax check: compare its returned endpoint, workspaceId, and SQL with the immutable ledger character-for-character. If any value differs, do not make a live request; rebuild the command from the confirmed literals and repeat dry-run. A dry-run is not evidence of server-side execution.SKILL_SESSION_ID={session-id} python3 scripts/adb_query.py \
--region-code <confirmed-region-code> \
--workspace-id <confirmed-workspace-id> \
--dry-run <<'SQL'
SHOW SCHEMAS FROM hive
SQL
When the user provides an endpoint, replace --region-code with --endpoint <confirmed-https-endpoint>.
adb_query.py tool invocation and returned output. Narration, progress text, todo state, or a remembered result is not execution evidence. In the rigid confirmed large-scan sequence, before the first SELECT, verify successful current-turn evidence in order for dry-run SHOW SCHEMAS, live SHOW SCHEMAS, SHOW TABLES, and DESCRIBE. If evidence is missing, execute the missing step instead of claiming it succeeded; never report schema columns that were not returned by that DESCRIBE.SHOW SCHEMAS, one SHOW TABLES, and one successful DESCRIBE before any SELECT. Do not skip DESCRIBE for COUNT(*), SELECT *, a user-named column, or an explicitly authorized aggregate. Only when it helps choose columns or interpret values, add one bounded sample after DESCRIBE. A simple COUNT(*), a query whose exact columns are confirmed by DESCRIBE, or a scoped cross-check does not require a sample solely for process compliance. In particular, do not sample rows or enumerate partitions merely to test whether a described goal column contains non-NULL values before presenting the exact aggregate plan. Add only the query needed for the confirmed goal; an explicitly requested independent cross-check may add one verification query.outputs/, ran_scripts/, reports, or helper files for generic task-wrapper logging. Only an artifact explicitly named in the user's analysis goal permits a file, and only after the requested query succeeds.Treat the following responses as terminal for the current endpoint, workspace, and OSS scope:
InvalidAccessToken, Invalid access token, AccessDenied, or an equivalent authorization failure;NoSuchBucket, NoSuchKey, workspace not found, bucket not found, prefix not found, or an equivalent confirmed resource-not-found failure;503 Service Temporarily Unavailable response;Cannot detect OSS file format, no supported files, or No files found for schema inference from an OSS table function.After a terminal response, preserve the redacted status, code, message, and requestId/queryId, explain which confirmed scope failed, and stop immediately. Make no further tool call for any reason; the failed live request must be the final tool result for the turn. Do not retry, sleep or back off, run a connectivity probe, read scripts or references, update a task list, increase the timeout, change the endpoint or workspace, probe a parent, child, or sibling OSS prefix, switch readers, or create a report, log, SQL file, or output directory. This immediate-stop rule overrides generic task-wrapper logging/output instructions and any earlier artifact plan; return the failure directly in the final response.
The only direct-file exception is a DESCRIBE files(...) failure that specifically proves the statement shape is unsupported, such as preparedQuery is null, does not have queryType, or an explicit unsupported-DESCRIBE message. That narrow error permits one SELECT ... FROM files(...) LIMIT 5 against the exact same prefix. A generic 5xx, permission error, resource-not-found error, or format-inference error does not permit the fallback.
Interpret the path as oss://{bucket}/{table-prefix}/...:
Start with:
SHOW SCHEMAS FROM hive
SHOW TABLES FROM hive.{validated_schema}.table-prefix as the required next input. In an interactive conversation, ask the user for it; when the current prompt requires a single-turn or non-interactive result, state the requirement declaratively and end the turn instead of waiting for a reply.Keep table selection as a metadata-only planning step. After SHOW SCHEMAS and SHOW TABLES, inspect at most the selected table with one DESCRIBE and one bounded LIMIT sample. Do not run COUNT(*), cross-table UNION ALL, unbounded SELECT DISTINCT, partition enumeration, or probes against multiple candidate tables to estimate size or choose a table. Those operations can scan large datasets before the user has approved a scope. If a planning query times out, do not retry it with a longer timeout or fan out more queries; present the narrower proposed scope and ask for confirmation.
DESCRIBE and require it to succeed before issuing any SELECT against that table. Add a bounded LIMIT query only when row contents are needed to choose columns or interpret values. A user-requested bounded row query, such as LIMIT 50 or LIMIT 100, can serve as the sample; do not issue a redundant smaller query solely to satisfy the example below.A successful registered-table match ends source selection for the current goal. Null-heavy samples or schema/data mismatches are data-quality findings, not evidence that the table is unregistered. Never turn such a finding into a choice between continuing with the registered table and probing raw OSS, and never offer a files(...) fallback when the user's source-selection rule allows it only for an unregistered table. If DESCRIBE already confirms the requested column, proceed to the exact goal SQL and its confirmation gate without exploratory partition samples. Pair each returned rows[n][i] value with columns[i] exactly as the Query API returns it. Semantic surprise alone is not proof of column reordering: do not relabel values or claim a schema/data mismatch merely because a value appears more plausible under another column name. Report a structural mismatch only when the response itself provides evidence, such as a row width that differs from the columns width. Do not solicit a source change; switch to a direct OSS table function only when the user independently and explicitly makes direct-file troubleshooting the new goal.
Registered-table examples:
DESCRIBE hive.{validated_schema}.{validated_table}
SELECT *
FROM hive.{validated_schema}.{validated_table}
LIMIT 20
When the format is unknown, try the unified entry point once:
DESCRIBE files(location => 'oss://bucket/table-prefix/')
If the service specifically reports that DESCRIBE is unsupported for the table function, preserve the redacted error and make one bounded fallback:
SELECT *
FROM files(location => 'oss://bucket/table-prefix/')
LIMIT 5
Rules:
hive_files(...) only after confirming a Hive-style key=value partition layout, and include partition predicates.parquet_file(...), csv_file(...), or json_file(...), even when a suffix or user statement appears to identify the format. Keeping one automatic entry point prevents format guessing and reader cycling.files(...) fallback fails, stop and report the redacted error. Ask the user to narrow or normalize the OSS prefix, or to register usable Hive metadata; do not request format, delimiter, header, or schema parameters for a format-specific retry.DESCRIBE files(...) attempt already returns a terminal permission, missing-resource, or format-inference error, stop without executing the bounded fallback.schema => 'auto' performs bounded listing and sampling during planning. Restrict the path before using it.SKILL_SESSION_ID={session-id} python3 scripts/adb_query.py \
--region-code <confirmed-region-code> \
--workspace-id <confirmed-workspace-id> <<'SQL'
SELECT *
FROM files(location => 'oss://confirmed-bucket/confirmed-prefix/')
LIMIT 20
SQL
The client sends JSON to:
POST {endpoint}/workspace/{workspaceId}/v1/query
Authorization: Bearer <selected runtime credential>
Content-Type: application/json
{"sql":"<presto-sql>"}
For an in-process caller, pass a user-supplied token through the client's access_token runtime parameter. For a subprocess, place the selected token only in the child process environment as ADB_ACCESS_TOKEN; do not interpolate it into a shell command or add a token command-line option. A child-process override takes precedence for that invocation and leaves the parent environment unchanged.
DESCRIBE already proves everything needed for the exact query.analysisGoal.LIMIT.COUNT(*) and unbounded partition discovery such as SELECT DISTINCT as large scans too; they cannot be used to bypass the confirmation gate during planning.The final response must include:
Never describe suggested SQL, a dry-run, HTTP 200, or an empty response as a completed data analysis. The analysis succeeds only when the HTTP request and SQL execution succeed and the returned data is sufficient to answer the confirmed goal.
The final response itself is the report. Do not create local artifacts for reproducibility, auditing, evaluator bookkeeping, or convenience. A file is allowed only when the user's actual analysis goal explicitly names that deliverable and the query succeeds. After a terminal error, no artifact request permits another tool call.
Treat a successful query with no returned rows as an empty result for that exact scope. Report that no data matched and include the filters or OSS scope; do not invent records, distributions, or explanations. Do not convert an empty row set into numeric zero unless an executed aggregate explicitly returned zero.
This workflow creates no cloud resources. Discard an explicit accessToken from task memory after the request. If this workflow temporarily created or replaced ADB_ACCESS_TOKEN in the current shell, restore the previous value; only unset it when the variable was created solely for this task:
unset ADB_ACCESS_TOKEN
Never delete OSS data, Hive metadata, or existing user files.
| File | Purpose |
|---|---|
| references/query-api.md | Query API protocol, client usage, and error handling |
| references/oss-table-functions.md | Allowed automatic OSS readers and their stopping rules |
| references/acceptance-criteria.md | Correct and incorrect behavior |
| references/verification-method.md | Local tests and release validation |