From 0802ed634b0f8a48b1e70bd4a66b48b4645cd33a Mon Sep 17 00:00:00 2001 From: "tao.chen" <93983997+taochen-ct@users.noreply.github.com> Date: Wed, 1 Jul 2026 18:38:43 +0800 Subject: [PATCH] feat: add pyspark script builder skill by wensichen --- skills/pyspark-script-builder/SKILL.md | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 skills/pyspark-script-builder/SKILL.md diff --git a/skills/pyspark-script-builder/SKILL.md b/skills/pyspark-script-builder/SKILL.md new file mode 100644 index 0000000..b544ebb --- /dev/null +++ b/skills/pyspark-script-builder/SKILL.md @@ -0,0 +1,47 @@ +--- +name: pyspark-script-builder +description: Use after sql-review to wrap reviewed_sql into a complete PySpark script. Inputs are reviewed_sql, app_name, and script_name; ask the user for app_name or script_name if missing; preserve reviewed_sql business logic and output app_name, script_name, and pyspark_code only. +--- + +# PySpark Script Builder + +Use this skill only after `sql-review`, when `reviewed_sql` is already available and the user needs it wrapped as a complete PySpark script. + +## Required Inputs + +- `reviewed_sql`: SQL text that has already been reviewed. +- `app_name`: Spark application name. If missing, ask the user before producing output. Do not invent or derive it. +- `script_name`: Script file name. If missing, ask the user before producing output. Do not invent or derive it. + +## Rules + +- Preserve the business logic of `reviewed_sql`. Do not rewrite tables, columns, predicates, joins, aggregations, ordering, limits, comments, or SQL semantics. +- Only wrap `reviewed_sql` in the fixed PySpark script structure below. +- Do not add file persistence, job creation, confirmation, cluster launch, queue/resource selection, monitoring, logs, or lifecycle steps. +- Escape `app_name` only as needed to keep a valid Python double-quoted string. +- Put `reviewed_sql` inside a raw triple-quoted string exactly in the `sql = r"""..."""` assignment. +- Do not run the SQL or validate it again; this skill only builds script text. + +## Output + +Return only these fields: + +- `app_name` +- `script_name` +- `pyspark_code` + +Build `pyspark_code` with this exact structure: + +```python +from pyspark.sql import SparkSession + +APP_NAME = "" + +def main(): + spark = SparkSession.builder.appName(APP_NAME).enableHiveSupport().getOrCreate() + sql = r"""""" + spark.sql(sql) + spark.stop() + +if __name__ == "__main__": main() +```