跳到正文
cccskills
免费在 GitHub 公开中文介绍

write-script-snowflake

本指南介绍在 Windmill 中编写 Snowflake SQL 脚本的方法,包括用 `?` 接收输入、处理数组和 S3 文件,以及将大量查询结果流式保存到 S3。

原文查看原文说明

MUST use when writing Snowflake queries.

windmill-labs/windmill星标 18,314(GitHub 18,314 + cccskills 0)

实测评分 未实测

查看安装方法

适用场景

  • 向 Snowflake 查询传入输入值
  • 用数组参数筛选结果
  • 将 S3 文件作为查询输入
  • 把大量查询结果保存到 S3

中文介绍

功能

本指南说明如何在 Windmill 中编写面向 Snowflake 的 SQL 脚本。输入值通过 ? 占位符传入;在 SQL 前写注释,可以声明参数名称、类型,以及可选的默认值。数组会以 JSON 文本形式传递,因此资料提供了使用 PARSE_JSON(?) 和 FLATTEN 的示例。对于 s3object 类型的输入,也介绍了如何在查询中读取所选文件。此外,脚本开头可以使用 s3 指令,将查询结果流式写入 S3,并保存为 JSON、Parquet 或 CSV 格式。

适用场景

需要从 Windmill 向 Snowflake 查询传值,或使用数组作为筛选条件时,可以参考本指南。它也适合将 S3 文件作为输入处理,或不直接返回大量行、而是把结果保存起来的情况。

使用示例

  • “编写一个接收姓名和年龄的 Snowflake 查询。”
  • “用数组参数筛选目标群组。”
  • “将查询结果以 Parquet 格式导出到 S3。”

注意事项

Snowflake 数组输入会绑定为 JSON 文本,应使用 PARSE_JSON(?) 处理。向 S3 输出结果需要 Windmill 的 S3 存储配置。

本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。

文档检查

AI 根据 SKILL.md 的内容检查了需要注意的操作和使用前提。评分只依据实际运行的结果(实测对比)。

安全性发送数据、删除文件、执行命令等是否有说明
B部分不足会执行查询并写入 S3,资料提及相关存储配置。
安装难易度所需工具和 API 密钥是否少且有说明
B部分不足需要 Windmill 和 Snowflake,S3 输出还需要存储配置。

不计入评分。 由 AI(OpenAI Codex)于 2026年10月28日 评估。仅供参考,安装前请同时查看原文。

如果您认为评估有误,请申请复核

请写明哪一项有误以及原因。无需登录。我们会对照 SKILL.md 重新评估,并在此处更新结果。

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

包含的文件(1)

  • SKILL.md10.9 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

CLI Commands

Place scripts in a folder.

After writing, tell the user which command fits what they want to do:

  • wmill script preview <script_path> — default when iterating on a local script. Runs the local file without deploying.
  • wmill script run <path> — runs the script already deployed in the workspace. Use only when the user explicitly wants to test the deployed version, not local edits.
  • wmill generate-metadata — regenerate the local .script.yaml (input schema) and .lock (resolved dependencies) for scripts you changed, and refresh their content hashes in wmill-lock.yaml. Local files only — not a deploy. See "Keep metadata in sync" below.
  • Deploy local changes to the workspace — via git push or wmill sync push depending on how the repo is wired (see the Deploying section in AGENTS.wmill.md). Only suggest/run a deploy when the user explicitly asks to deploy/publish/push — not when they say "run", "try", or "test".

Preview vs run — choose by intent, not habit

If the user says "run the script", "try it", "test it", "does it work" while there are local edits to the script file, use script preview. Do NOT push the script to then script run it — pushing is a deploy, and deploying just to test overwrites the workspace version with untested changes.

Only use script run when:

  • The user explicitly says "run the deployed version" / "run what's on the server".
  • There is no local script being edited (you're just invoking an existing script).

Only use sync push when:

  • The user explicitly asks to deploy, publish, push, or ship.
  • The preview has already validated the change and the user wants it in the workspace.

Keep metadata in sync after editing

wmill-lock.yaml tracks a content hash for each item. Editing a script's content — most importantly adding or removing an import or changing main's arguments — invalidates that hash and leaves the .lock, the .script.yaml input schema, and the hash row out of date. Run wmill generate-metadata (scoped to what you touched) after such edits so the resolved lock, the auto-generated args UI (driven by .script.yaml), and wmill-lock.yaml all match the code. Leaving them stale produces spurious diffs in git-sync and CI.

This only writes local files (it is not a deploy), but it re-resolves dependencies, so it can bump unpinned versions (the same as deploying from the UI; expected, not a bug). So by default offer it and run it once the user agrees, rather than running it silently after every edit — unless the project's AGENTS.md opts into running metadata automatically (see the "Keeping metadata in sync" preference there). Either way YOU run the command, not the user. After running it, diff the regenerated .lock / .script.lock files and tell the user which dependency versions changed (e.g. requests 2.31.0 → 2.32.0), so they can catch an unwanted bump before deploying — even under Metadata: auto, since it's information, not a confirmation gate. Pin versions in code to keep them fixed.

With no path argument, generate-metadata regenerates only the items whose content hash drifted — not everything. Imports propagate: editing a script that others import marks every importer stale too, so a one-line change to a shared module can regenerate many locks (by design — their locks must reflect the imported code). If it touches more than you expect, run wmill generate-metadata --dry-run — it lists each stale item with a reason (content changed or depends on <path>) without changing anything — then narrow with a path argument (wmill generate-metadata f/foo) or --strict-folder-boundaries.

If the on-disk .lock and .script.yaml are already correct and only wmill-lock.yaml needs its hashes refreshed (hash drift, or bootstrapping missing entries), use wmill generate-metadata rehash — it re-records hashes from disk with no backend round-trip and no dependency changes.

After writing — offer to test, don't wait passively

If the user hasn't already told you to run/test/preview the script, offer it as a one-sentence next step (e.g. "Want me to run wmill script preview with sample args?"). Do not present a multi-option menu.

If the user already asked to test/run/try the script in their original request, skip the offer and just execute wmill script preview <path> -d '<args>' directly — pick plausible args from the script's declared parameters. The shape varies by language: main(...) for code languages, the SQL dialect's own placeholder syntax ($1 for PostgreSQL, ? for MySQL/Snowflake, @P1 for MSSQL, @name for BigQuery, etc.), positional $1, $2, … for Bash, param(...) for PowerShell.

wmill script preview does not deploy, but it still executes script code and may cause side effects; run it yourself when the user asked to test/preview (or after confirming that execution is intended). wmill generate-metadata does not deploy either — it only writes local files (locks, schemas, hashes) — but offer it before running (or run automatically if the project's AGENTS.md opts in), per "Keep metadata in sync" above. Deploying to the workspace (git push or wmill sync push depending on how the repo is wired — see the Deploying section) is the only step that mutates remote state — do it only when the user explicitly asks to deploy/publish/push.

For a visual open-the-script-in-the-dev-page preview (rather than script preview's run-and-print-result), use the preview skill.

Use wmill resource-type list --schema to discover available resource types.

Windmill Script Writing Guide

General Principles

  • A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
  • When no resource type exists for a service, still take its connection as one resource-typed parameter, of a custom type holding the connection fields (base URL, account identifiers, credentials), its secret in a variable the resource references. A custom type is named c_<name>, which keeps it apart from a hub type synced later: the parameter takes RT.C<Name> in TypeScript, a c_<name> TypedDict in Python. A plain string parameter or a variable read inside the code only when the user asks for it: the resource keeps a connection's fields together, lets whoever runs the script pick an existing connection, and keeps the secret out of the arguments a run records. If the instance is reported as not having synced the Windmill Hub's resource types, mention that a superadmin can sync them, since the hub has types for most services. Otherwise, or when the user prefers it to syncing, propose the resource type and ask before creating it
  • A Windmill Hub script takes a resource type the hub publishes, so on an instance that has not synced the hub's types that type is missing: say so, and that a superadmin can sync them, before asking for a resource of it. Hub scripts often declare the type inline (type Stripe = { token: string }), which is still the stripe resource type; in code you write, name it the way the language section shows (RT.Stripe in TypeScript) rather than copying the inline declaration
  • Before relying on a resource type, a hub script's included, run wmill resource-type list: it shows whether the workspace has the type, and warns when the instance has not synced the hub's types
  • Libraries are installed automatically - do not show installation instructions
  • In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it main (Main in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no main: their language section shows how they take arguments
  • Where the language has a Windmill client (wmill), use it to interact with the platform
  • A script's input schema may carry a top-level prompt_for_ai string: its author's instructions to an AI choosing the inputs. Follow it when you pick arguments to run that script, and keep it when you rewrite the schema

Return Values

  • A script can return any JSON-serializable value; a SQL script returns the rows its query produces
  • Return values become available to subsequent flow steps via results.step_id

Preprocessor Scripts

Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.

A preprocessor is written in TypeScript or Python: its function is named preprocessor instead of main, and it receives a single parameter called event (the language section gives its type).

The returned object determines the parameter values passed to the flow. e.g., { b: 1, a: 2 } calls the flow with a = 2 and b = 1, assuming the flow has two inputs called a and b.

Snowflake

Arguments use ? placeholders.

Name the parameters by adding comments before the statement:

-- ? name1 (text)
-- ? name2 (number) = 0
SELECT * FROM users WHERE name = ? AND age > ?;

Array parameters

Declare a list with a [] suffix on the element type ((varchar[]), (int[])), or (array) for an untyped one. Snowflake cannot bind an array directly, so Windmill binds the list as JSON text: wrap the placeholder with PARSE_JSON(?), and cast to ARRAY where a function expects one.

-- ? groups (varchar[])
SELECT o.* FROM orders o
WHERE ARRAY_CONTAINS(o.owner_group::VARIANT, PARSE_JSON(?)::ARRAY);

Or join on the elements with FLATTEN:

-- ? groups (varchar[])
SELECT o.* FROM orders o
JOIN TABLE(FLATTEN(input => PARSE_JSON(?))) g ON g.value::STRING = o.owner_group;

Receiving an S3Object as a script parameter

Declare the arg with type (s3object). Windmill renders an S3 file picker for it, downloads the file, and binds it as JSON text — Parquet/CSV files are decoded server-side into a JSON array of records, JSON/JSONL pass through. Wrap the bind with PARSE_JSON(?) and walk it with LATERAL FLATTEN:

-- ? file (s3object)
SELECT
  v.value:id::NUMBER AS id,
  v.value:name::STRING AS name
FROM LATERAL FLATTEN(input => PARSE_JSON(?)) v;

Streaming query results to S3

Add a -- s3 directive at the top of the script to stream the result set to S3 instead of returning rows. Windmill writes the file and returns its S3Object as the script result.

-- s3 prefix=exports/users format=parquet
SELECT id, name FROM users;

All keys are optional: prefix (object key prefix), storage (named storage — omit to use the workspace default), format (json (default), parquet, or csv). Use this for large result sets — rows stream directly to S3 instead of being buffered, bypassing the 10000-row return cap.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Plan the code changes needed to add a TriggerCrud-based trigger to Windmill. The checklist covers backend, database, API, CLI, frontend, capture, and validation work so the new trigger can be managed across the product.

中文简介正在准备中。当前显示英语简介。

  • Add a Kafka, GCP, or Azure style trigger to Windmill
  • Find all product areas affected by a new trigger kind
  • Review implementation and validation steps before a trigger PR
windmill-labs/windmill1.8万2026年10月29日 更新

agents

免费有简介

在 Windmill 中定义可复用的 AI 智能体,为其配置指令、提供方、模型、对话记忆和工具。保存后可从页面运行、供流程步骤调用,或分享到 Slack 频道。

  • 创建可复用的客服智能体
  • 在流程中调用已保存的智能体
  • 将智能体分享到 Slack 频道
windmill-labs/windmill1.8万2026年10月29日 更新

ai-chat

免费有简介

改进 Windmill AI 聊天时,可梳理工具、提示词、结果格式和上下文用量。指南说明如何放置共享指令、减少重复消耗,并通过 A/B 评估比较改动前后的行为。

  • 调整聊天工具及其结果格式
  • 检查提示词的放置位置
  • 减少上下文窗口用量
windmill-labs/windmill1.8万2026年10月29日 更新

ai-evals

免费有简介

为 Windmill 的 AI 生成模式创建并运行黑盒基准测试,覆盖流程、应用、脚本、CLI 和全局请求。案例经过实际生成路径、硬性检查和大语言模型评判,可比较修改前后的面向用户表现。

  • 为 AI 生成模式添加评估案例
  • 比较 AI 聊天修改前后的表现
  • 检查 copilot 生成质量
windmill-labs/windmill1.8万2026年10月29日 更新

cli-commands

免费有简介

这份参考资料介绍如何用 Windmill CLI 管理脚本、流程、数据表和工作区设置,并查看作业历史、详情、日志与结果,排查失败及重新运行作业。

  • 排查作业失败原因
  • 查看运行历史和作业日志
  • 通过 CLI 管理脚本和流程
windmill-labs/windmill1.8万2026年10月29日 更新

codebase-design

免费有简介

帮助设计接口简洁、内部承载较多处理逻辑的模块,梳理模块边缘与复杂度,减少调用方需要了解的内容,让代码更易测试和维护。

  • 设计模块接口
  • 梳理复杂的现有模块
  • 确定可替换处理的位置
windmill-labs/windmill1.8万2026年10月29日 更新

查看 windmill-labs 的全部技能

报告此技能的问题