[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6ACJR50ZS7F1QX58JEKCGVM":3,"skill-same:01M6ACJR50ZS7F1QX58JEKCGVM":87},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":52,"linkOnly":53,"markdownContent":54,"markdownBody":55,"frontMatter":56,"refName":58,"commitSha":59,"skillDirectory":60,"forksCount":61,"repositoryHtmlUrl":62,"repositoryHomepageUrl":63,"ownerHtmlUrl":64,"ownerBlogUrl":65,"ownerDescription":17,"updatedAt":66,"install":67,"resources":80},"01M6ACJR50ZS7F1QX58JEKCGVM","wire-datafusion-function","DataFusion 函数接入 Comet","Use when wiring an existing DataFusion or datafusion-spark function into Comet for a Spark expression. Identifies the right wiring pattern (one-line passthrough, datafusion-spark UDF registration, or custom serde with input massaging \u002F restrictions), applies the Scala serde, registers the UDF in jni_api when needed, and adds SQL file tests. Assumes the function already exists upstream — if not, switch to `implement-comet-expression`.","在将现有的 DataFusion 或 datafusion-spark 函数接入 Comet 以支持某个 Spark 表达式时使用。识别正确的接入模式（一行式透传、datafusion-spark UDF 注册，或带输入处理\u002F限制的自定义 serde），应用 Scala serde，在需要时在 jni_api 中注册 UDF，并添加 SQL 文件测试。假定该函数在上游已存在——如果不存在，则切换到 `implement-comet-expression`。","apache\u002Fdatafusion-comet","apache","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F47359?v=4","01M6AC83E6K4FDKK7HZ8WNMQKE","The Apache Software Foundation","01M6ACHX42TPNCR8TQJEAR8J5J",1322,"Apache-2.0",null,"https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-comet\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Fwire-datafusion-function\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师","PROFESSION","适用职业",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BT7QVANT4709358VEJK53E","代码实现","SCENARIO","使用场景",[31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],"datafusion","wire datafusion function","registration","when","wiring","custom","Existing","for","with","expression","name","tests","upstream","implement","switch","use","api","file","spark","scala","sql","2026-11-10 10:12:30",false,"---\nname: wire-datafusion-function\ndescription: Use when wiring an existing DataFusion or datafusion-spark function into Comet for a Spark expression. Identifies the right wiring pattern (one-line passthrough, datafusion-spark UDF registration, or custom serde with input massaging \u002F restrictions), applies the Scala serde, registers the UDF in jni_api when needed, and adds SQL file tests. Assumes the function already exists upstream — if not, switch to `implement-comet-expression`.\nargument-hint: \u003Cexpression-name>\n---\n\n\u003C!--\nLicensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements.  See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership.  The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\"License\"); you may not use this file except in compliance\nwith the License.  You may obtain a copy of the License at\n\n  http:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\nUnless required by applicable law or agreed to in writing,\nsoftware distributed under the License is distributed on an\n\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, either express or implied.  See the License for the\nspecific language governing permissions and limitations\nunder the License.\n-->\n\nWire Comet support for the `$ARGUMENTS` Spark expression by reusing an existing DataFusion or `datafusion-spark` function. **No native Rust is written here** — if upstream coverage is missing, stop and run `implement-comet-expression`.\n\n## Wiring patterns\n\nPick the lightest one that satisfies the Spark contract.\n\n| Pattern                        | When                                                                                                                                                                                                                                                                     | What to change                                                                                                                                                                   |\n| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| **A** — passthrough            | DF built-in (e.g. `acos`), or `datafusion-spark` UDF already registered in `register_datafusion_spark_function`                                                                                                                                                          | one line in the right map of `QueryPlanSerde.scala`: `classOf[Foo] -> CometScalarFunction(\"foo\")`                                                                                |\n| **B** — register + passthrough | `datafusion-spark` UDF, _not_ yet registered, semantics already match Spark                                                                                                                                                                                              | Pattern A line **plus** `session_ctx.register_udf(ScalarUDF::new_from_impl(SparkFoo::default()));` in `native\u002Fcore\u002Fsrc\u002Fexecution\u002Fjni_api.rs::register_datafusion_spark_function` |\n| **C** — custom serde           | Inputs need preprocessing (cast, `nullIfNegative`, `+0.0` flip), or you need to set return type \u002F `failOnError`, restrict input types via `getSupportLevel`, enforce foldable-only args, or attach `getCompatibleNotes`\u002F`getIncompatibleReasons`\u002F`getUnsupportedReasons` | new `CometXxx` object in the topic file (`math.scala`, `strings.scala`, …); see `CometCeil`, `CometAtan2`, `CometLog`, `CometSha2`, `CometAbs`                                   |\n\nFunction names must match: the string passed to `CometScalarFunction(\"xyz\")` equals `SparkXyz::name()` upstream.\n\n## Workflow\n\n### 1. Study the Spark contract\n\nFind the `case class $ARGUMENTS` (PascalCase). Prefer the user's local Spark clone (agent instructions \u002F project memory); fall back to `git clone --depth 1 https:\u002F\u002Fgithub.com\u002Fapache\u002Fspark.git \u002Ftmp\u002Fspark-master`. If the clone is sandbox-blocked and no local clone is found, **stop and ask** — Spark is the ground truth.\n\nNote `inputTypes`, `dataType`, `eval` \u002F `nullSafeEval`, `require` guards, ANSI mode branches, and foldable-only arguments. These define what Comet must reproduce.\n\n### 2. Find the upstream function (at the pinned version)\n\nThe pinned versions in `native\u002FCargo.toml` are the ground truth — a function on upstream `main` may not exist in the version Comet depends on. Resolve versions first, then search sources matching those exact versions. **Pick one source path; do not mix.**\n\n```bash\nREPO_ROOT=$(git rev-parse --show-toplevel)\n# Portable regex — BSD awk on macOS does not support \\b.\nDF_SPARK_VER=$(awk -F'\"' '\u002F^datafusion-spark[ =]\u002F {print $2; exit}' \"$REPO_ROOT\u002Fnative\u002FCargo.toml\")\nDF_FUNCS_VER=$(awk -F'\"' '\u002F^datafusion[ =]\u002F        {print $2; exit}' \"$REPO_ROOT\u002Fnative\u002FCargo.toml\")\n[ -z \"$DF_SPARK_VER\" ] || [ -z \"$DF_FUNCS_VER\" ] && { echo \"ERROR: version extraction failed\"; exit 1; }\nEXPR='$ARGUMENTS'\n```\n\n**Option A — cargo registry (preferred):**\n\n```bash\nDF_SPARK=$(ls -d ~\u002F.cargo\u002Fregistry\u002Fsrc\u002F*\u002Fdatafusion-spark-${DF_SPARK_VER}\u002F 2>\u002Fdev\u002Fnull | head -1)\nDF_FUNCS=$(ls -d ~\u002F.cargo\u002Fregistry\u002Fsrc\u002F*\u002Fdatafusion-functions-${DF_FUNCS_VER}\u002F 2>\u002Fdev\u002Fnull | head -1)\n# If empty, run `cargo fetch` from native\u002F.\ngrep -rin \"fn name\" \"$DF_SPARK\u002Fsrc\u002Ffunction\u002F\" 2>\u002Fdev\u002Fnull | grep -i \"$EXPR\"\ngrep -rin \"fn name\" \"$DF_FUNCS\u002Fsrc\u002F\"          2>\u002Fdev\u002Fnull | grep -i \"$EXPR\"\n```\n\n**Option B — local DataFusion clone** (only if agent instructions \u002F memory point at one). Grep at the pinned tag — DataFusion uses lightweight tags (`\u003Cversion>`, no `v` prefix), so use `tag -l` not `rev-parse --verify ^{tag}`:\n\n```bash\nDF_CLONE=\u003Cpath from memory>\n[ -z \"$(git -C \"$DF_CLONE\" tag -l \"$DF_SPARK_VER\")\" ] && echo \"WARNING: tag missing — git fetch --tags or use Option A\"\ngit -C \"$DF_CLONE\" grep -in \"fn name\" \"$DF_SPARK_VER\" -- 'datafusion\u002Fspark\u002Fsrc\u002Ffunction\u002F' | grep -i \"$EXPR\"\ngit -C \"$DF_CLONE\" grep -in \"fn name\" \"$DF_FUNCS_VER\" -- 'datafusion\u002Ffunctions\u002Fsrc\u002F'      | grep -i \"$EXPR\"\n```\n\nNever grep the clone's working tree directly — it may be on `main`.\n\n### 2a. Decision gate — confirm the source crate\n\n- **Found in `datafusion-spark`** → proceed (Spark-tuned by design). If listed in `register_datafusion_spark_function` → Pattern A; otherwise Pattern B.\n- **Found only in `datafusion-functions`** → **STOP and `AskUserQuestion`**. Pure DataFusion follows standard SQL semantics and frequently diverges from Spark (NULL vs error, negatives, overflow, return type, NaN). Surface what you found in each crate and the divergences you've already identified, then offer:\n  1. Wire from `datafusion-functions` with Pattern C bridging — list the divergences and the masking\u002Fcasting that closes them.\n  2. Stop and switch to `implement-comet-expression` to port to `datafusion-spark` upstream first.\n- **Found in neither** → stop and run `implement-comet-expression`.\n\nIf semantics diverge in a way Pattern C can't bridge, escalate.\n\n### 3. Apply the Scala wiring\n\nAdd the entry to the matching map in `spark\u002Fsrc\u002Fmain\u002Fscala\u002Forg\u002Fapache\u002Fcomet\u002Fserde\u002FQueryPlanSerde.scala`: `mathExpressions`, `stringExpressions`, `arrayExpressions`, `mapExpressions`, `structExpressions`, `predicateExpressions`, `conditionalExpressions`, `bitwiseExpressions`, `temporalExpressions`, `hashExpressions`, `conversionExpressions`, `miscExpressions`.\n\nSpark expression classes are in scope via `import org.apache.spark.sql.catalyst.expressions._`. For Pattern C, the topic file uses **explicit** imports — extend the existing `import …expressions.{…}` line and place the new object alongside its peers.\n\nHelpers from `QueryPlanSerde`:\n\n- `scalarFunctionExprToProto(name, args*)` — return type inferred, `failOnError = false`.\n- `scalarFunctionExprToProtoWithReturnType(name, returnType, failOnError, args*)` — explicit type \u002F fail-on-error.\n- `optExprWithInfo(optExpr, expr, children*)` — wrap final result; propagates \"why we couldn't convert\" tags.\n- `withInfo(expr, \"reason\")` — tag a fallback when returning `None`.\n\nIf the Spark behavior you are matching varies by Spark version, resolve the version in Scala and pass the native side a parameter, or pick a function name, that describes the behavior rather than the version (see \"Name the behavior, not the Spark version\" in `adding_a_new_expression.md`).\n\n`getSupportLevel` returning `Incompatible(Some(\"…\"))` gates behind `spark.comet.expr.\u003Cname>.allowIncompatible=true`. `Unsupported(…)` always falls back.\n\n### 4. Register the UDF (Pattern B only)\n\nIn `native\u002Fcore\u002Fsrc\u002Fexecution\u002Fjni_api.rs::register_datafusion_spark_function`, add the `use` and the `register_udf` line, grouped with neighbors. Patterns A and C never touch native code.\n\n### 5. Add SQL file tests\n\nCreate `spark\u002Fsrc\u002Ftest\u002Fresources\u002Fsql-tests\u002Fexpressions\u002F\u003Ccategory>\u002F$ARGUMENTS.sql`. Mandatory rules:\n\n1. **Test only the directly supported input types** — read `inputTypes` from the Spark source. Do **not** add columns for implicit-cast widening (`ImplicitCastInputTypes`); the cast path has its own tests. E.g. `inputTypes = Seq(IntegerType)` (`Factorial`) → one `int` column, not byte\u002Fshort\u002Flong\u002Ffloat\u002Fdouble\u002Fdecimal. For `TypeCollection(A, B)`, add one column per member.\n2. **All `SELECT`s read from a parquet table** — no literal-only queries (the constant folder skips the read path and column-vector kernel).\n3. **Mix `NULL` into every column** — exercises the validity bitmap.\n4. **Per type, cover the edge-case set:**\n   - Float \u002F Double: `NaN`, `+0.0`, `-0.0`, `±Infinity` via `cast('NaN' as double)` etc.\n   - Integer \u002F decimal: each type's max and min (`127`\u002F`-128`, `2147483647`\u002F`-2147483648`, `9223372036854775807`\u002F`-9223372036854775808`, `Decimal(38, 0)` boundary) for overflow \u002F wrap.\n   - String \u002F binary: empty, multi-byte UTF-8 (`'é'`, `'日本'`), embedded NULs if relevant.\n5. **Cover the Spark-specific edges** found in step 1: in-range boundaries, just-out-of-range values, ANSI error paths, foldable-only args.\n\nUse `query expect_fallback(...)` for inputs where the serde returns `None`. Format: `docs\u002Fsource\u002Fcontributor-guide\u002Fsql-file-tests.md`.\n\n### 6. Update docs\n\nHand-curated (`make` does not regenerate these):\n\n- `docs\u002Fsource\u002Fuser-guide\u002Flatest\u002Fexpressions.md` — add `| \u003CExpressionClass> | \\`\u003Csql_name>\\` |` to the matching category table, alphabetical.\n- `docs\u002Fsource\u002Fuser-guide\u002Flatest\u002Fexpressions.md` — update the function's Status from ?\u002F? to ✅ (or ⚠️) in the matching category table.\n\nPer-expression compatibility pages under `compatibility\u002Fexpressions\u002F*.md` are auto-generated from `getCompatibleNotes` \u002F `getIncompatibleReasons` \u002F `getUnsupportedReasons` — do not hand-edit.\n\n### 7. Build, audit, finalize\n\n```bash\nmake\ncd native && cargo clippy --all-targets --workspace -- -D warnings\n```\n\nThen run `audit-comet-expression` on `$ARGUMENTS` to compare against Spark 3.4.3 \u002F 3.5.8 \u002F 4.0.1 and surface coverage gaps; iterate on tests.\n\nThe user generally runs tests themselves. If asked for a smoke test:\n\n```bash\n.\u002Fmvnw test -Dsuites=\"org.apache.comet.CometSqlFileTestSuite $ARGUMENTS\" -Dtest=none\n```\n\nPR: fill in `.github\u002Fpull_request_template.md`; under \"What changes are included\", note the skill was used and which upstream function (`datafusion::…` built-in or `datafusion-spark::function::…`) is being wired.\n","\u003C!--\nLicensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements.  See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership.  The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\"License\"); you may not use this file except in compliance\nwith the License.  You may obtain a copy of the License at\n\n  http:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\nUnless required by applicable law or agreed to in writing,\nsoftware distributed under the License is distributed on an\n\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, either express or implied.  See the License for the\nspecific language governing permissions and limitations\nunder the License.\n-->\n\nWire Comet support for the `$ARGUMENTS` Spark expression by reusing an existing DataFusion or `datafusion-spark` function. **No native Rust is written here** — if upstream coverage is missing, stop and run `implement-comet-expression`.\n\n## Wiring patterns\n\nPick the lightest one that satisfies the Spark contract.\n\n| Pattern                        | When                                                                                                                                                                                                                                                                     | What to change                                                                                                                                                                   |\n| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| **A** — passthrough            | DF built-in (e.g. `acos`), or `datafusion-spark` UDF already registered in `register_datafusion_spark_function`                                                                                                                                                          | one line in the right map of `QueryPlanSerde.scala`: `classOf[Foo] -> CometScalarFunction(\"foo\")`                                                                                |\n| **B** — register + passthrough | `datafusion-spark` UDF, _not_ yet registered, semantics already match Spark                                                                                                                                                                                              | Pattern A line **plus** `session_ctx.register_udf(ScalarUDF::new_from_impl(SparkFoo::default()));` in `native\u002Fcore\u002Fsrc\u002Fexecution\u002Fjni_api.rs::register_datafusion_spark_function` |\n| **C** — custom serde           | Inputs need preprocessing (cast, `nullIfNegative`, `+0.0` flip), or you need to set return type \u002F `failOnError`, restrict input types via `getSupportLevel`, enforce foldable-only args, or attach `getCompatibleNotes`\u002F`getIncompatibleReasons`\u002F`getUnsupportedReasons` | new `CometXxx` object in the topic file (`math.scala`, `strings.scala`, …); see `CometCeil`, `CometAtan2`, `CometLog`, `CometSha2`, `CometAbs`                                   |\n\nFunction names must match: the string passed to `CometScalarFunction(\"xyz\")` equals `SparkXyz::name()` upstream.\n\n## Workflow\n\n### 1. Study the Spark contract\n\nFind the `case class $ARGUMENTS` (PascalCase). Prefer the user's local Spark clone (agent instructions \u002F project memory); fall back to `git clone --depth 1 https:\u002F\u002Fgithub.com\u002Fapache\u002Fspark.git \u002Ftmp\u002Fspark-master`. If the clone is sandbox-blocked and no local clone is found, **stop and ask** — Spark is the ground truth.\n\nNote `inputTypes`, `dataType`, `eval` \u002F `nullSafeEval`, `require` guards, ANSI mode branches, and foldable-only arguments. These define what Comet must reproduce.\n\n### 2. Find the upstream function (at the pinned version)\n\nThe pinned versions in `native\u002FCargo.toml` are the ground truth — a function on upstream `main` may not exist in the version Comet depends on. Resolve versions first, then search sources matching those exact versions. **Pick one source path; do not mix.**\n\n```bash\nREPO_ROOT=$(git rev-parse --show-toplevel)\n# Portable regex — BSD awk on macOS does not support \\b.\nDF_SPARK_VER=$(awk -F'\"' '\u002F^datafusion-spark[ =]\u002F {print $2; exit}' \"$REPO_ROOT\u002Fnative\u002FCargo.toml\")\nDF_FUNCS_VER=$(awk -F'\"' '\u002F^datafusion[ =]\u002F        {print $2; exit}' \"$REPO_ROOT\u002Fnative\u002FCargo.toml\")\n[ -z \"$DF_SPARK_VER\" ] || [ -z \"$DF_FUNCS_VER\" ] && { echo \"ERROR: version extraction failed\"; exit 1; }\nEXPR='$ARGUMENTS'\n```\n\n**Option A — cargo registry (preferred):**\n\n```bash\nDF_SPARK=$(ls -d ~\u002F.cargo\u002Fregistry\u002Fsrc\u002F*\u002Fdatafusion-spark-${DF_SPARK_VER}\u002F 2>\u002Fdev\u002Fnull | head -1)\nDF_FUNCS=$(ls -d ~\u002F.cargo\u002Fregistry\u002Fsrc\u002F*\u002Fdatafusion-functions-${DF_FUNCS_VER}\u002F 2>\u002Fdev\u002Fnull | head -1)\n# If empty, run `cargo fetch` from native\u002F.\ngrep -rin \"fn name\" \"$DF_SPARK\u002Fsrc\u002Ffunction\u002F\" 2>\u002Fdev\u002Fnull | grep -i \"$EXPR\"\ngrep -rin \"fn name\" \"$DF_FUNCS\u002Fsrc\u002F\"          2>\u002Fdev\u002Fnull | grep -i \"$EXPR\"\n```\n\n**Option B — local DataFusion clone** (only if agent instructions \u002F memory point at one). Grep at the pinned tag — DataFusion uses lightweight tags (`\u003Cversion>`, no `v` prefix), so use `tag -l` not `rev-parse --verify ^{tag}`:\n\n```bash\nDF_CLONE=\u003Cpath from memory>\n[ -z \"$(git -C \"$DF_CLONE\" tag -l \"$DF_SPARK_VER\")\" ] && echo \"WARNING: tag missing — git fetch --tags or use Option A\"\ngit -C \"$DF_CLONE\" grep -in \"fn name\" \"$DF_SPARK_VER\" -- 'datafusion\u002Fspark\u002Fsrc\u002Ffunction\u002F' | grep -i \"$EXPR\"\ngit -C \"$DF_CLONE\" grep -in \"fn name\" \"$DF_FUNCS_VER\" -- 'datafusion\u002Ffunctions\u002Fsrc\u002F'      | grep -i \"$EXPR\"\n```\n\nNever grep the clone's working tree directly — it may be on `main`.\n\n### 2a. Decision gate — confirm the source crate\n\n- **Found in `datafusion-spark`** → proceed (Spark-tuned by design). If listed in `register_datafusion_spark_function` → Pattern A; otherwise Pattern B.\n- **Found only in `datafusion-functions`** → **STOP and `AskUserQuestion`**. Pure DataFusion follows standard SQL semantics and frequently diverges from Spark (NULL vs error, negatives, overflow, return type, NaN). Surface what you found in each crate and the divergences you've already identified, then offer:\n  1. Wire from `datafusion-functions` with Pattern C bridging — list the divergences and the masking\u002Fcasting that closes them.\n  2. Stop and switch to `implement-comet-expression` to port to `datafusion-spark` upstream first.\n- **Found in neither** → stop and run `implement-comet-expression`.\n\nIf semantics diverge in a way Pattern C can't bridge, escalate.\n\n### 3. Apply the Scala wiring\n\nAdd the entry to the matching map in `spark\u002Fsrc\u002Fmain\u002Fscala\u002Forg\u002Fapache\u002Fcomet\u002Fserde\u002FQueryPlanSerde.scala`: `mathExpressions`, `stringExpressions`, `arrayExpressions`, `mapExpressions`, `structExpressions`, `predicateExpressions`, `conditionalExpressions`, `bitwiseExpressions`, `temporalExpressions`, `hashExpressions`, `conversionExpressions`, `miscExpressions`.\n\nSpark expression classes are in scope via `import org.apache.spark.sql.catalyst.expressions._`. For Pattern C, the topic file uses **explicit** imports — extend the existing `import …expressions.{…}` line and place the new object alongside its peers.\n\nHelpers from `QueryPlanSerde`:\n\n- `scalarFunctionExprToProto(name, args*)` — return type inferred, `failOnError = false`.\n- `scalarFunctionExprToProtoWithReturnType(name, returnType, failOnError, args*)` — explicit type \u002F fail-on-error.\n- `optExprWithInfo(optExpr, expr, children*)` — wrap final result; propagates \"why we couldn't convert\" tags.\n- `withInfo(expr, \"reason\")` — tag a fallback when returning `None`.\n\nIf the Spark behavior you are matching varies by Spark version, resolve the version in Scala and pass the native side a parameter, or pick a function name, that describes the behavior rather than the version (see \"Name the behavior, not the Spark version\" in `adding_a_new_expression.md`).\n\n`getSupportLevel` returning `Incompatible(Some(\"…\"))` gates behind `spark.comet.expr.\u003Cname>.allowIncompatible=true`. `Unsupported(…)` always falls back.\n\n### 4. Register the UDF (Pattern B only)\n\nIn `native\u002Fcore\u002Fsrc\u002Fexecution\u002Fjni_api.rs::register_datafusion_spark_function`, add the `use` and the `register_udf` line, grouped with neighbors. Patterns A and C never touch native code.\n\n### 5. Add SQL file tests\n\nCreate `spark\u002Fsrc\u002Ftest\u002Fresources\u002Fsql-tests\u002Fexpressions\u002F\u003Ccategory>\u002F$ARGUMENTS.sql`. Mandatory rules:\n\n1. **Test only the directly supported input types** — read `inputTypes` from the Spark source. Do **not** add columns for implicit-cast widening (`ImplicitCastInputTypes`); the cast path has its own tests. E.g. `inputTypes = Seq(IntegerType)` (`Factorial`) → one `int` column, not byte\u002Fshort\u002Flong\u002Ffloat\u002Fdouble\u002Fdecimal. For `TypeCollection(A, B)`, add one column per member.\n2. **All `SELECT`s read from a parquet table** — no literal-only queries (the constant folder skips the read path and column-vector kernel).\n3. **Mix `NULL` into every column** — exercises the validity bitmap.\n4. **Per type, cover the edge-case set:**\n   - Float \u002F Double: `NaN`, `+0.0`, `-0.0`, `±Infinity` via `cast('NaN' as double)` etc.\n   - Integer \u002F decimal: each type's max and min (`127`\u002F`-128`, `2147483647`\u002F`-2147483648`, `9223372036854775807`\u002F`-9223372036854775808`, `Decimal(38, 0)` boundary) for overflow \u002F wrap.\n   - String \u002F binary: empty, multi-byte UTF-8 (`'é'`, `'日本'`), embedded NULs if relevant.\n5. **Cover the Spark-specific edges** found in step 1: in-range boundaries, just-out-of-range values, ANSI error paths, foldable-only args.\n\nUse `query expect_fallback(...)` for inputs where the serde returns `None`. Format: `docs\u002Fsource\u002Fcontributor-guide\u002Fsql-file-tests.md`.\n\n### 6. Update docs\n\nHand-curated (`make` does not regenerate these):\n\n- `docs\u002Fsource\u002Fuser-guide\u002Flatest\u002Fexpressions.md` — add `| \u003CExpressionClass> | \\`\u003Csql_name>\\` |` to the matching category table, alphabetical.\n- `docs\u002Fsource\u002Fuser-guide\u002Flatest\u002Fexpressions.md` — update the function's Status from ?\u002F? to ✅ (or ⚠️) in the matching category table.\n\nPer-expression compatibility pages under `compatibility\u002Fexpressions\u002F*.md` are auto-generated from `getCompatibleNotes` \u002F `getIncompatibleReasons` \u002F `getUnsupportedReasons` — do not hand-edit.\n\n### 7. Build, audit, finalize\n\n```bash\nmake\ncd native && cargo clippy --all-targets --workspace -- -D warnings\n```\n\nThen run `audit-comet-expression` on `$ARGUMENTS` to compare against Spark 3.4.3 \u002F 3.5.8 \u002F 4.0.1 and surface coverage gaps; iterate on tests.\n\nThe user generally runs tests themselves. If asked for a smoke test:\n\n```bash\n.\u002Fmvnw test -Dsuites=\"org.apache.comet.CometSqlFileTestSuite $ARGUMENTS\" -Dtest=none\n```\n\nPR: fill in `.github\u002Fpull_request_template.md`; under \"What changes are included\", note the skill was used and which upstream function (`datafusion::…` built-in or `datafusion-spark::function::…`) is being wired.\n",{"name":5,"description":7,"argument-hint":57},"\u003Cexpression-name>","main","7deeba21a42e4a9cd34f43e7ed6e960e4e851b26",".ai\u002Fskills\u002Fwire-datafusion-function",418,"https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-comet","https:\u002F\u002Fdatafusion.apache.org\u002Fcomet","https:\u002F\u002Fgithub.com\u002Fapache","https:\u002F\u002Fwww.apache.org\u002F","2026-11-15 03:15:20",{"source":9,"skillName":5,"commands":68,"prompt":78,"zipAvailable":79},[69,72,75],{"tool":70,"command":71},"npx","npx skills add apache\u002Fdatafusion-comet --skill wire-datafusion-function",{"tool":73,"command":74},"bunx","bunx skills add apache\u002Fdatafusion-comet --skill wire-datafusion-function",{"tool":76,"command":77},"pnpm","pnpm dlx skills add apache\u002Fdatafusion-comet --skill wire-datafusion-function","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-comet\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Fwire-datafusion-function\u002FSKILL.md",true,[81],{"path":82,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":85,"sourceHtmlUrl":86},"OWNERSHIP","OTHER","其他",24,"https:\u002F\u002Fgithub.com\u002FJetBrains\u002Fintellij-community\u002Fblob\u002Fmaster\u002F.agents\u002Fskills\u002Frust-code-style\u002FOWNERSHIP",[88,120,147,168,183,202],{"skillNo":89,"name":90,"nameZh":91,"description":92,"descriptionZh":93,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":94,"categories":95,"keywords":100,"publishedAt":52},"01M6ACJPDDPND6FHE2PC1CJ4D3","suggest-native-expression","Spark 表达式原生实现评估","Use when picking the next Spark expression to implement natively in Comet, or when asked whether a specific codegen-dispatched expression is worth a native Rust implementation. Scores the candidate on how likely a native path can be 100% Spark-compatible and how much throughput or allocation it would save versus the JVM codegen dispatcher, records the verdict in the per-expression audit log so disqualified candidates are not re-litigated, and files a GitHub issue for the recommendation.","在选择下一个要在 Comet 中原生实现的 Spark 表达式时使用，或被问及某个特定的 codegen 分派表达式是否值得用原生 Rust 实现时使用。该技能根据原生路径达到 100% Spark 兼容性的可能性，以及相对于 JVM codegen 分派器能节省多少吞吐量或内存分配，对候选表达式进行评分；将结论记录在按表达式划分的审计日志中，以免不合格的候选被重复讨论，并为该建议提交一个 GitHub issue。","https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-comet\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Fsuggest-native-expression\u002FSKILL.md",[96,97],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":98,"categoryName":99,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BSNPHVX9Y1H3B2ZX3V06RF","Rust 开发",[101,40,102,103,104,105,44,49,106,107,34,108,109,110,111,112,113,114,115,116,117,118,119],"suggest native expression","native","dispatcher","github","rust","re","files","candidate","log","jvm","next","how","audit","audit log","allocation","issue","throughput","path","save",{"skillNo":121,"name":122,"nameZh":123,"description":124,"descriptionZh":125,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":126,"categories":127,"keywords":132,"publishedAt":52},"01M6ACJMHPEN7E76VPKC3P4X6C","review-comet-shuffle-pr","Comet Shuffle PR 审查","Use when reviewing a DataFusion Comet pull request that touches native or JVM columnar shuffle, the shuffle writers and readers, partitioning, the Arrow IPC block format, shuffle compression, or the Celeborn integration. Load alongside review-comet-pr.","在审查涉及原生或 JVM 列式 shuffle、shuffle 写入器与读取器、分区、Arrow IPC 块格式、shuffle 压缩或 Celeborn 集成的 DataFusion Comet 拉取请求时使用。应与 review-comet-pr 一起加载。","https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-comet\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Freview-comet-shuffle-pr\u002FSKILL.md",[128,129],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":130,"categoryName":131,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BR5V701HCN066VEP7H4812","代码仓库协作管理",[133,134,135,136,137,31,138,46,139,34,140,141,110,102,142,143,144,145,146],"review comet shuffle pr","pr","review","pull","pull request","arrow","load","ipc","number","request","format","integration","block","compression",{"skillNo":148,"name":149,"nameZh":150,"description":151,"descriptionZh":152,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":153,"categories":154,"keywords":157,"publishedAt":52},"01M6ACJHX8BES7ZNNRNVCQ4QWE","review-comet-pr","DataFusion Comet PR 审查","Use when reviewing a DataFusion Comet pull request. Covers the workflow that applies to every PR and routes to the area-specific review skills for expressions, FFI, memory management, shuffle, Iceberg writes, and documentation. Provides guidance to a human reviewer rather than posting comments.","在审查 DataFusion Comet 拉取请求（pull request）时使用。涵盖适用于每个 PR 的工作流程，并路由到针对表达式、FFI、内存管理、shuffle、Iceberg 写入和文档的领域专项审查技能。为人工审查者提供指导，而非直接发布评论。","https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-comet\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Freview-comet-pr\u002FSKILL.md",[155,156],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":130,"categoryName":131,"taxonomyType":28,"taxonomyTypeDesc":29},[134,135,158,136,159,137,160,31,161,162,34,141,163,164,142,165,38,46,166,167],"review comet pr","iceberg","memory","workflow","documentation","reviewer","human","posting","review skills","comments",{"skillNo":169,"name":170,"nameZh":171,"description":172,"descriptionZh":173,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":174,"categories":175,"keywords":178,"publishedAt":52},"01M6ACJFM0QS61Z1RW516HXN2M","review-comet-memory-pr","Comet 内存管理 PR 审查","Use when reviewing a DataFusion Comet pull request that touches memory pools, memory reservations, spilling, the Spark TaskMemoryManager bridge, allocators, or memory-related configuration. Load alongside review-comet-pr.","在审查 DataFusion Comet 的拉取请求（PR）时使用，该请求涉及内存池、内存预留、溢写（spilling）、Spark TaskMemoryManager 桥接、内存分配器或与内存相关的配置。需与 review-comet-pr 一起加载。","https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-comet\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Freview-comet-memory-pr\u002FSKILL.md",[176,177],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":130,"categoryName":131,"taxonomyType":28,"taxonomyTypeDesc":29},[134,160,179,135,136,137,31,49,180,181,46,139,34,141,142,182],"review comet memory pr","bridge","reservations","configuration",{"skillNo":184,"name":185,"nameZh":186,"description":187,"descriptionZh":188,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":189,"categories":190,"keywords":193,"publishedAt":52},"01M6ACJCV64V0FZPMVXDE2K3DX","review-comet-iceberg-write-pr","Comet Iceberg 写入 PR 审查","Use when reviewing a DataFusion Comet pull request that touches Iceberg writes, the split-operator write plan (IcebergWriteStrategy, IcebergWriteExec, IcebergCommitExec), the native Iceberg writer (CometIcebergWriteExec, iceberg_write.rs, iceberg_partition_path.rs), its eligibility gate (CometIcebergNativeWrite), or the iceberg-rust pin. Load alongside review-comet-pr.","在审查 DataFusion Comet 的拉取请求（PR）时使用，该请求涉及 Iceberg 写入、拆分算子写入计划（IcebergWriteStrategy、IcebergWriteExec、IcebergCommitExec）、原生 Iceberg 写入器（CometIcebergWriteExec、iceberg_write.rs、iceberg_partition_path.rs）、其适用性门槛（CometIcebergNativeWrite）或 iceberg-rust 的版本锁定（pin）。需与 review-comet-pr 一起加载。","https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-comet\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Freview-comet-iceberg-write-pr\u002FSKILL.md",[191,192],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":130,"categoryName":131,"taxonomyType":28,"taxonomyTypeDesc":29},[134,159,194,135,195,136,137,31,105,196,197,198,46,139,199,34,141,200,201,102],"review comet iceberg write pr","write","writer","write plan","partition","pin","split","plan",{"skillNo":203,"name":204,"nameZh":205,"description":206,"descriptionZh":207,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":208,"categories":209,"keywords":212,"publishedAt":52},"01M6ACJA72KJRAM6F7WHMX01PN","review-comet-ffi-pr","Comet FFI 边界 PR 审查","Use when reviewing a DataFusion Comet pull request that crosses the JVM\u002Fnative boundary, touching Arrow C Data or C Stream interface code, batch export and import, CometExecIterator, ScanExec, NativeUtil, CometVector subclasses, or jni_api. Load alongside review-comet-pr.","在审查 DataFusion Comet 的拉取请求（PR）时使用，该请求跨越 JVM\u002F原生代码边界，涉及 Arrow C Data 或 C Stream 接口代码、批次导出与导入、CometExecIterator、ScanExec、NativeUtil、CometVector 子类或 jni_api。需与 review-comet-pr 一起加载。","https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-comet\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Freview-comet-ffi-pr\u002FSKILL.md",[210,211],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":130,"categoryName":131,"taxonomyType":28,"taxonomyTypeDesc":29},[134,213,135,214,136,137,31,138,215,216,217,218,46,139,34,141,47,110,219,102,142],"review comet ffi pr","ffi","code","batch","import","interface","boundary"]