[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6ACKX5JQ505Q8YX7BJTGQBM":3,"skill-same:01M6ACKX5JQ505Q8YX7BJTGQBM":83},{"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":7,"sourceHtmlUrl":17,"categories":18,"keywords":29,"publishedAt":31,"linkOnly":32,"markdownContent":33,"markdownBody":34,"frontMatter":35,"refName":36,"commitSha":37,"skillDirectory":38,"forksCount":39,"repositoryHtmlUrl":40,"repositoryHomepageUrl":41,"ownerHtmlUrl":42,"ownerBlogUrl":43,"ownerDescription":7,"updatedAt":44,"install":45,"resources":58},"01M6ACKX5JQ505Q8YX7BJTGQBM","check-upstream","上游代码更新检查",null,"","apache\u002Fdatafusion-python","apache","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F47359?v=4","01M6AC83E6K4FDKK7HZ8WNMQKE","The Apache Software Foundation","01M6ACKST0XJWJESE0ZMQG0W2M",613,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-python\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Fcheck-upstream\u002FSKILL.md",[19,24],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师","PROFESSION","适用职业",{"categoryNo":25,"categoryName":26,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BR5V701HCN066VEP7H4812","代码仓库协作管理","SCENARIO","使用场景",[30],"check upstream","2026-11-10 10:12:30",false,"---\nname: check-upstream\ndescription: Check if upstream Apache DataFusion features (functions, DataFrame ops, SessionContext methods, FFI types) are exposed in this Python project. Use when adding missing functions, auditing API coverage, or ensuring parity with upstream.\nargument-hint: [area] (e.g., \"scalar functions\", \"aggregate functions\", \"window functions\", \"dataframe\", \"session context\", \"ffi types\", \"all\")\n---\n\n\u003C!---\n  Licensed to the Apache Software Foundation (ASF) under one\n  or more contributor license agreements.  See the NOTICE file\n  distributed with this work for additional information\n  regarding copyright ownership.  The ASF licenses this file\n  to you under the Apache License, Version 2.0 (the\n  \"License\"); you may not use this file except in compliance\n  with the License.  You may obtain a copy of the License at\n\n    http:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an\n  \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n  KIND, either express or implied.  See the License for the\n  specific language governing permissions and limitations\n  under the License.\n-->\n\n# Check Upstream DataFusion Feature Coverage\n\nYou are auditing the datafusion-python project to find features from the upstream Apache DataFusion Rust library that are **not yet exposed** in this Python binding project. Your goal is to identify gaps and, if asked, implement the missing bindings.\n\n**IMPORTANT: The Python API is the source of truth for coverage.** A function or method is considered \"exposed\" if it exists in the Python API (e.g., `python\u002Fdatafusion\u002Ffunctions.py`), even if there is no corresponding entry in the Rust bindings. Many upstream functions are aliases of other functions — the Python layer can expose these aliases by calling a different underlying Rust binding. Do NOT report a function as missing if it appears in the Python `__all__` list and has a working implementation, regardless of whether a matching `#[pyfunction]` exists in Rust.\n\n**IMPORTANT: audit the total upstream surface, not the delta since the last pin.** Gaps accumulate across syncs. A patch-release bump with a \"bug fixes only\" changelog does not mean there is nothing to find — pre-existing gaps from earlier majors still need to be surfaced. Always run the full comparison.\n\n## Compile-Signal Triggers\n\nIf a recent upstream bump required *any* of the following while fixing\ncompile errors in `crates\u002Fcore\u002F` or the FFI example, treat that as a\n**hard signal** that user-facing surface area grew and run this skill\nbefore considering the bump done. Each pattern corresponds to a class of\ngap that frequently shows up in the audit:\n\n| Signal during PR 1 compile fix | Likely gap to check |\n|---|---|\n| New `Expr::*` variant added to a non-exhaustive `match` (`HigherOrderFunction`, `Lambda`, `LambdaVariable`, …) | New lambda \u002F higher-order scalar functions (`any_match`, `array_transform`, `list_transform`, …) |\n| New `ScalarValue::*` variant (`ListView`, `LargeListView`, …) | New scalar \u002F array functions that consume or produce the type |\n| New required trait method on `ExecutionPlan` \u002F `TableProvider` \u002F `*UDFImpl` (`apply_expressions`, …) | Corresponding capability on the Python wrapper class |\n| Renamed or restructured struct field (e.g. `Cast.data_type` → `Cast.field: FieldRef`) | Any Python accessor \u002F SKILL.md doc that read the old field |\n| Newly deprecated trait method with a `_with_args` \u002F `_with_options` replacement | The `*_with_options` variant frequently warrants a separate Python entry point |\n\nPR 1 of `dev\u002Frelease\u002Fupstream-sync.md` asks you to log these signals as\nthey appear. When you run this skill, use that log as a checklist: every\nentry must either show up in the audit output or be explicitly skipped\nwith a reason.\n\n## Areas to Check\n\nThe user may specify an area via `$ARGUMENTS`. If no area is specified or \"all\" is given, check all areas.\n\n### 1. Scalar Functions\n\n**Upstream source of truth:**\n- Rust docs: https:\u002F\u002Fdocs.rs\u002Fdatafusion\u002Flatest\u002Fdatafusion\u002Ffunctions\u002Findex.html\n- User docs: https:\u002F\u002Fdatafusion.apache.org\u002Fuser-guide\u002Fsql\u002Fscalar_functions.html\n\n**Where they are exposed in this project:**\n- Python API: `python\u002Fdatafusion\u002Ffunctions.py` — each function wraps a call to `datafusion._internal.functions`\n- Rust bindings: `crates\u002Fcore\u002Fsrc\u002Ffunctions.rs` — `#[pyfunction]` definitions registered via `init_module()`\n\n**Evaluated and not requiring separate Python exposure:**\n- `get_field_path` — already covered by `get_field(expr, *names)`, which takes a\n  variadic field path and dispatches to the same underlying\n  `functions::core::get_field` UDF as the upstream `get_field_path` helper.\n\n**How to check:**\n1. Fetch the upstream scalar function documentation page\n2. Compare against functions listed in `python\u002Fdatafusion\u002Ffunctions.py` (check the `__all__` list and function definitions)\n3. A function is covered if it exists in the Python API — it does NOT need a dedicated Rust `#[pyfunction]`. Many functions are aliases that reuse another function's Rust binding.\n4. Check against the \"evaluated and not requiring exposure\" list before flagging as a gap\n5. Only report functions that are missing from the Python `__all__` list \u002F function definitions\n\n### 2. Aggregate Functions\n\n**Upstream source of truth:**\n- Rust docs: https:\u002F\u002Fdocs.rs\u002Fdatafusion\u002Flatest\u002Fdatafusion\u002Ffunctions_aggregate\u002Findex.html\n- User docs: https:\u002F\u002Fdatafusion.apache.org\u002Fuser-guide\u002Fsql\u002Faggregate_functions.html\n\n**Where they are exposed in this project:**\n- Python API: `python\u002Fdatafusion\u002Ffunctions.py` (aggregate functions are mixed in with scalar functions)\n- Rust bindings: `crates\u002Fcore\u002Fsrc\u002Ffunctions.rs`\n\n**Evaluated and not requiring separate Python exposure:**\n- `count_distinct` — covered by `count(expr, distinct=True)`. Both forms call\n  `count_udaf` with `distinct: bool = true` and produce the same logical plan.\n- `sum_distinct` — covered by `sum(expr, distinct=True)`.\n- `avg_distinct` — covered by `avg(expr, distinct=True)`.\n\n**How to check:**\n1. Fetch the upstream aggregate function documentation page\n2. Compare against aggregate functions in `python\u002Fdatafusion\u002Ffunctions.py` (check `__all__` list and function definitions)\n3. A function is covered if it exists in the Python API, even if it aliases another function's Rust binding\n4. Check against the \"evaluated and not requiring exposure\" list before flagging as a gap\n5. Report only functions missing from the Python API\n\n### 3. Window Functions\n\n**Upstream source of truth:**\n- Rust docs: https:\u002F\u002Fdocs.rs\u002Fdatafusion\u002Flatest\u002Fdatafusion\u002Ffunctions_window\u002Findex.html\n- User docs: https:\u002F\u002Fdatafusion.apache.org\u002Fuser-guide\u002Fsql\u002Fwindow_functions.html\n\n**Where they are exposed in this project:**\n- Python API: `python\u002Fdatafusion\u002Ffunctions.py` (window functions like `rank`, `dense_rank`, `lag`, `lead`, etc.)\n- Rust bindings: `crates\u002Fcore\u002Fsrc\u002Ffunctions.rs`\n\n**How to check:**\n1. Fetch the upstream window function documentation page\n2. Compare against window functions in `python\u002Fdatafusion\u002Ffunctions.py` (check `__all__` list and function definitions)\n3. A function is covered if it exists in the Python API, even if it aliases another function's Rust binding\n4. Report only functions missing from the Python API\n\n### 4. Table Functions\n\n**Upstream source of truth:**\n- Rust docs: https:\u002F\u002Fdocs.rs\u002Fdatafusion\u002Flatest\u002Fdatafusion\u002Ffunctions_table\u002Findex.html\n- User docs: https:\u002F\u002Fdatafusion.apache.org\u002Fuser-guide\u002Fsql\u002Ftable_functions.html (if available)\n\n**Where they are exposed in this project:**\n- Python API: `python\u002Fdatafusion\u002Ffunctions.py` and `python\u002Fdatafusion\u002Fuser_defined.py` (TableFunction\u002Fudtf)\n- Rust bindings: `crates\u002Fcore\u002Fsrc\u002Ffunctions.rs` and `crates\u002Fcore\u002Fsrc\u002Fudtf.rs`\n\n**How to check:**\n1. Fetch the upstream table function documentation\n2. Compare against what's available in the Python API\n3. A function is covered if it exists in the Python API, even if it aliases another function's Rust binding\n4. Report only functions missing from the Python API\n\n### 5. DataFrame Operations\n\n**Upstream source of truth:**\n- Rust docs: https:\u002F\u002Fdocs.rs\u002Fdatafusion\u002Flatest\u002Fdatafusion\u002Fdataframe\u002Fstruct.DataFrame.html\n\n**Where they are exposed in this project:**\n- Python API: `python\u002Fdatafusion\u002Fdataframe.py` — the `DataFrame` class\n- Rust bindings: `crates\u002Fcore\u002Fsrc\u002Fdataframe.rs` — `PyDataFrame` with `#[pymethods]`\n\n**Evaluated and not requiring separate Python exposure:**\n- `show_limit` — already covered by `DataFrame.show()`, which provides the same functionality with a simpler API\n- `with_param_values` — already covered by the `param_values` argument on `SessionContext.sql()`, which accomplishes the same thing more robustly\n- `union_by_name_distinct` — already covered by `DataFrame.union_by_name(distinct=True)`, which provides a more Pythonic API\n- `to_string` — `str(df)` is the Pythonic way to get a string and already goes through `__repr__` and the configurable formatter. A separate `to_string()` would either duplicate `str(df)` or render every row through a different path (session `datafusion.format.*` options, no formatter), giving a third text rendering alongside `repr` and `show()`\n\n**How to check:**\n1. Fetch the upstream DataFrame documentation page listing all methods\n2. Compare against methods in `python\u002Fdatafusion\u002Fdataframe.py` — this is the source of truth for coverage\n3. The Rust bindings (`crates\u002Fcore\u002Fsrc\u002Fdataframe.rs`) may be consulted for context, but a method is covered if it exists in the Python API\n4. Check against the \"evaluated and not requiring exposure\" list before flagging as a gap\n5. Report only methods missing from the Python API\n\n### 6. SessionContext Methods\n\n**Upstream source of truth:**\n- Rust docs: https:\u002F\u002Fdocs.rs\u002Fdatafusion\u002Flatest\u002Fdatafusion\u002Fexecution\u002Fcontext\u002Fstruct.SessionContext.html\n\n**Where they are exposed in this project:**\n- Python API: `python\u002Fdatafusion\u002Fcontext.py` — the `SessionContext` class\n- Rust bindings: `crates\u002Fcore\u002Fsrc\u002Fcontext.rs` — `PySessionContext` with `#[pymethods]`\n\n**How to check:**\n1. Fetch the upstream SessionContext documentation page listing all methods\n2. Compare against methods in `python\u002Fdatafusion\u002Fcontext.py` — this is the source of truth for coverage\n3. The Rust bindings (`crates\u002Fcore\u002Fsrc\u002Fcontext.rs`) may be consulted for context, but a method is covered if it exists in the Python API\n4. Report only methods missing from the Python API\n\n### 7. FFI Types (datafusion-ffi)\n\n**Upstream source of truth:**\n- Crate source: https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion\u002Ftree\u002Fmain\u002Fdatafusion\u002Fffi\u002Fsrc\n- Rust docs: https:\u002F\u002Fdocs.rs\u002Fdatafusion-ffi\u002Flatest\u002Fdatafusion_ffi\u002F\n\n**Where they are exposed in this project:**\n- Rust bindings: various files under `crates\u002Fcore\u002Fsrc\u002F` and `crates\u002Futil\u002Fsrc\u002F`\n- FFI example: `examples\u002Fdatafusion-ffi-example\u002Fsrc\u002F`\n- Dependency declared in root `Cargo.toml` and `crates\u002Fcore\u002FCargo.toml`\n\n**Discovering currently supported FFI types:**\nGrep for `use datafusion_ffi::` in `crates\u002Fcore\u002Fsrc\u002F` and `crates\u002Futil\u002Fsrc\u002F` to find all FFI types currently imported and used.\n\n**Evaluated and not requiring direct Python exposure:**\nThese upstream FFI types have been reviewed and do not need to be independently exposed to end users:\n- `FFI_ExecutionPlan` — already used indirectly through table providers; no need for direct exposure\n- `FFI_PhysicalExpr` \u002F `FFI_PhysicalSortExpr` — internal physical planning types not expected to be needed by end users\n- `FFI_RecordBatchStream` — one level deeper than FFI_ExecutionPlan, used internally when execution plans stream results\n- `FFI_SessionRef` \u002F `ForeignSession` — session sharing across FFI; Python manages sessions natively via SessionContext\n- `FFI_SessionConfig` — Python can configure sessions natively without FFI\n- `FFI_ConfigOptions` \u002F `FFI_TableOptions` — internal configuration plumbing\n- `FFI_PlanProperties` \u002F `FFI_Boundedness` \u002F `FFI_EmissionType` — read from existing plans, not user-facing\n- `FFI_Partitioning` — supporting type for physical planning\n- Supporting\u002Futility types (`FFI_Option`, `FFI_Result`, `WrappedSchema`, `WrappedArray`, `FFI_ColumnarValue`, `FFI_Volatility`, `FFI_InsertOp`, `FFI_AccumulatorArgs`, `FFI_Accumulator`, `FFI_GroupsAccumulator`, `FFI_EmitTo`, `FFI_AggregateOrderSensitivity`, `FFI_PartitionEvaluator`, `FFI_PartitionEvaluatorArgs`, `FFI_Range`, `FFI_SortOptions`, `FFI_Distribution`, `FFI_ExprProperties`, `FFI_SortProperties`, `FFI_Interval`, `FFI_TableProviderFilterPushDown`, `FFI_TableType`) — used as building blocks within the types above, not independently exposed\n\n**How to check:**\n1. Discover currently supported types by grepping for `use datafusion_ffi::` in `crates\u002Fcore\u002Fsrc\u002F` and `crates\u002Futil\u002Fsrc\u002F`, then compare against the upstream `datafusion-ffi` crate's `lib.rs` exports\n2. If new FFI types appear upstream, evaluate whether they represent a user-facing capability\n3. Check against the \"evaluated and not requiring exposure\" list before flagging as a gap\n4. Report any genuinely new types that enable user-facing functionality\n5. For each currently supported FFI type, verify the full pipeline is present using the checklist from \"Adding a New FFI Type\":\n   - Rust PyO3 wrapper with `from_pycapsule()` method\n   - Python Protocol type (e.g., `ScalarUDFExportable`) for FFI objects\n   - Python wrapper class with full type hints on all public methods\n   - ABC base class (if the type can be user-implemented)\n   - Registered in Rust `init_module()` and Python `__init__.py`\n   - FFI example in `examples\u002Fdatafusion-ffi-example\u002F`\n   - Type appears in union type hints where accepted\n\n### 8. Spark-Compatible Functions (`datafusion-spark` crate)\n\n**Upstream source of truth:**\n- Crate source: https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion\u002Ftree\u002Fmain\u002Fdatafusion\u002Fspark\u002Fsrc\n- Rust docs: https:\u002F\u002Fdocs.rs\u002Fdatafusion-spark\u002Flatest\u002Fdatafusion_spark\u002F\n\n**Where they are exposed in this project:**\n- Python API: `python\u002Fdatafusion\u002Ffunctions\u002Fspark.py` — each function wraps\n  a call to `datafusion._internal.functions.spark`; the public surface is\n  the module's `__all__` list.\n- Rust bindings: `crates\u002Fcore\u002Fsrc\u002Fspark_functions.rs` — `#[pyfunction]`\n  definitions registered via `init_module()` and re-exported under\n  `datafusion._internal.functions.spark`.\n\n**Coverage policy:** The spark namespace mirrors\n`pyspark.sql.functions` parameter names and shapes exactly so pyspark\ncallers can paste code unchanged. Extras over pyspark are permitted as\nlong as positional pyspark calls still work — for example, the spark\n`avg` \u002F `try_sum` \u002F `collect_list` \u002F `collect_set` retain the\n`distinct`\u002F`filter`\u002F`order_by`\u002F`null_treatment` kwargs from the main\nnamespace while pyspark's single-positional form continues to work.\n\n**How to check:**\n1. Fetch the upstream `datafusion-spark` function list from the crate\n   source under `datafusion\u002Fspark\u002Fsrc\u002Ffunction\u002F` (each subdirectory is a\n   category: `string\u002F`, `math\u002F`, `datetime\u002F`, etc.). The crate's\n   `function.rs` collects all `ScalarUDF` factories.\n2. Cross-reference against `pyspark.sql.functions` for the public-facing\n   shape — pyspark is the contract this namespace is matching.\n3. Compare against the functions listed in\n   `python\u002Fdatafusion\u002Ffunctions\u002Fspark.py`'s `__all__`. A function is\n   covered if it exists in the Python `spark` namespace, even if it\n   aliases another function's Rust binding.\n4. Report functions that are missing from the Python spark namespace.\n\n### 9. `__all__` Hygiene (functions.py and functions\u002Fspark.py)\n\nIndependent of upstream parity, also flag public `def` symbols in\n`python\u002Fdatafusion\u002Ffunctions.py` **and** `python\u002Fdatafusion\u002Ffunctions\u002Fspark.py`\nthat are missing from that file's `__all__`. These are functions a user\ncan call but that do not show up in\n`from datafusion.functions import *`, in tab-completion against the\nnamespace, or in generated API docs — typically an oversight rather than\nan intentional omission.\n\n**How to check:**\n1. Grep for `^def ([a-z_][a-z0-9_]*)\\(` in each file to enumerate every\n   public function definition.\n2. Read the `__all__` list at the top of the same file.\n3. Report any function in (1) that is not in (2). Skip private helpers\n   (names starting with `_`).\n\nA historical example: `instr` and `position` shipped as public `def`s but\nwere absent from `__all__` until the gap was caught here.\n\nFor each finding, propose adding the name to `__all__` in alphabetical\nposition with the existing entries.\n\n## Checking for Existing GitHub Issues\n\nAfter identifying missing APIs, search the open issues at https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-python\u002Fissues for each gap to see if an issue already exists requesting that API be exposed. Search using the function or method name as the query.\n\n- If an existing issue is found, include a link to it in the report. Do NOT create a new issue.\n- If no existing issue is found, note that no issue exists yet. If the user asks to create issues for missing APIs, each issue should specify that Python test coverage is required as part of the implementation.\n\n## Output Format\n\nFor each area checked, produce a report like:\n\n```\n## [Area Name] Coverage Report\n\n### Currently Exposed (X functions\u002Fmethods)\n- list of what's already available\n\n### Missing from Upstream (Y functions\u002Fmethods)\n- function_name — brief description of what it does (existing issue: #123)\n- function_name — brief description of what it does (no existing issue)\n\n### Notes\n- Any relevant observations about partial implementations, naming differences, etc.\n```\n\n## Implementation Pattern\n\nIf the user asks you to implement missing features, follow these patterns:\n\n### Adding a New Function (Scalar\u002FAggregate\u002FWindow)\n\n**Step 1: Rust binding** in `crates\u002Fcore\u002Fsrc\u002Ffunctions.rs`:\n```rust\n#[pyfunction]\n#[pyo3(signature = (arg1, arg2))]\nfn new_function_name(arg1: PyExpr, arg2: PyExpr) -> PyResult\u003CPyExpr> {\n    Ok(datafusion::functions::module::expr_fn::new_function_name(arg1.expr, arg2.expr).into())\n}\n```\nThen register in `init_module()`:\n```rust\nm.add_wrapped(wrap_pyfunction!(new_function_name))?;\n```\n\n**Step 2: Python wrapper** in `python\u002Fdatafusion\u002Ffunctions.py`:\n```python\ndef new_function_name(arg1: Expr, arg2: Expr) -> Expr:\n    \"\"\"Description of what the function does.\n\n    Args:\n        arg1: Description of first argument.\n        arg2: Description of second argument.\n\n    Returns:\n        Description of return value.\n    \"\"\"\n    return Expr(f.new_function_name(arg1.expr, arg2.expr))\n```\nAdd to `__all__` list.\n\n### Adding a New DataFrame Method\n\n**Step 1: Rust binding** in `crates\u002Fcore\u002Fsrc\u002Fdataframe.rs`:\n```rust\n#[pymethods]\nimpl PyDataFrame {\n    fn new_method(&self, py: Python, param: PyExpr) -> PyDataFusionResult\u003CSelf> {\n        let df = self.df.as_ref().clone().new_method(param.into())?;\n        Ok(Self::new(df))\n    }\n}\n```\n\n**Step 2: Python wrapper** in `python\u002Fdatafusion\u002Fdataframe.py`:\n```python\ndef new_method(self, param: Expr) -> DataFrame:\n    \"\"\"Description of the method.\"\"\"\n    return DataFrame(self.df.new_method(param.expr))\n```\n\n### Adding a New SessionContext Method\n\n**Step 1: Rust binding** in `crates\u002Fcore\u002Fsrc\u002Fcontext.rs`:\n```rust\n#[pymethods]\nimpl PySessionContext {\n    pub fn new_method(&self, py: Python, param: String) -> PyDataFusionResult\u003CPyDataFrame> {\n        let df = wait_for_future(py, self.ctx.new_method(&param))?;\n        Ok(PyDataFrame::new(df))\n    }\n}\n```\n\n**Step 2: Python wrapper** in `python\u002Fdatafusion\u002Fcontext.py`:\n```python\ndef new_method(self, param: str) -> DataFrame:\n    \"\"\"Description of the method.\"\"\"\n    return DataFrame(self.ctx.new_method(param))\n```\n\n### Adding a New FFI Type\n\nFFI types require a full pipeline from C struct through to a typed Python wrapper. Each layer must be present.\n\n**Step 1: Rust PyO3 wrapper class** in a new or existing file under `crates\u002Fcore\u002Fsrc\u002F`:\n```rust\nuse datafusion_ffi::new_type::FFI_NewType;\n\n#[pyclass(from_py_object, frozen, name = \"RawNewType\", module = \"datafusion.module_name\", subclass)]\npub struct PyNewType {\n    pub inner: Arc\u003Cdyn NewTypeTrait>,\n}\n\n#[pymethods]\nimpl PyNewType {\n    #[staticmethod]\n    fn from_pycapsule(obj: &Bound\u003C'_, PyAny>) -> PyDataFusionResult\u003CSelf> {\n        let capsule = obj\n            .getattr(\"__datafusion_new_type__\")?\n            .call0()?\n            .downcast::\u003CPyCapsule>()?;\n        let ffi_ptr = unsafe { capsule.reference::\u003CFFI_NewType>() };\n        let provider: Arc\u003Cdyn NewTypeTrait> = ffi_ptr.into();\n        Ok(Self { inner: provider })\n    }\n\n    fn some_method(&self) -> PyResult\u003C...> {\n        \u002F\u002F wrap inner trait method\n    }\n}\n```\nRegister in the appropriate `init_module()`:\n```rust\nm.add_class::\u003CPyNewType>()?;\n```\n\n**Step 2: Python Protocol type** in the appropriate Python module (e.g., `python\u002Fdatafusion\u002Fcatalog.py`):\n```python\nclass NewTypeExportable(Protocol):\n    \"\"\"Type hint for objects providing a __datafusion_new_type__ PyCapsule.\"\"\"\n\n    def __datafusion_new_type__(self) -> object: ...\n```\n\n**Step 3: Python wrapper class** in the same module:\n```python\nclass NewType:\n    \"\"\"Description of the type.\n\n    This class wraps a DataFusion NewType, which can be created from a native\n    Python implementation or imported from an FFI-compatible library.\n    \"\"\"\n\n    def __init__(\n        self,\n        new_type: df_internal.module_name.RawNewType | NewTypeExportable,\n    ) -> None:\n        if isinstance(new_type, df_internal.module_name.RawNewType):\n            self._raw = new_type\n        else:\n            self._raw = df_internal.module_name.RawNewType.from_pycapsule(new_type)\n\n    def some_method(self) -> ReturnType:\n        \"\"\"Description of the method.\"\"\"\n        return self._raw.some_method()\n```\n\n**Step 4: ABC base class** (if users should be able to subclass and provide custom implementations in Python):\n```python\nfrom abc import ABC, abstractmethod\n\nclass NewTypeProvider(ABC):\n    \"\"\"Abstract base class for implementing a custom NewType in Python.\"\"\"\n\n    @abstractmethod\n    def some_method(self) -> ReturnType:\n        \"\"\"Description of the method.\"\"\"\n        ...\n```\n\n**Step 5: Module exports** — add to the appropriate `__init__.py`:\n- Add the wrapper class (`NewType`) to `python\u002Fdatafusion\u002F__init__.py`\n- Add the ABC (`NewTypeProvider`) if applicable\n- Add the Protocol type (`NewTypeExportable`) if it should be public\n\n**Step 6: FFI example** — add an example implementation under `examples\u002Fdatafusion-ffi-example\u002Fsrc\u002F`:\n```rust\n\u002F\u002F examples\u002Fdatafusion-ffi-example\u002Fsrc\u002Fnew_type.rs\nuse datafusion_ffi::new_type::FFI_NewType;\n\u002F\u002F ... example showing how an external Rust library exposes this type via PyCapsule\n```\n\n**Checklist for each FFI type:**\n- [ ] Rust PyO3 wrapper with `from_pycapsule()` method\n- [ ] Python Protocol type (e.g., `NewTypeExportable`) for FFI objects\n- [ ] Python wrapper class with full type hints on all public methods\n- [ ] ABC base class (if the type can be user-implemented)\n- [ ] Registered in Rust `init_module()` and Python `__init__.py`\n- [ ] FFI example in `examples\u002Fdatafusion-ffi-example\u002F`\n- [ ] Type appears in union type hints where accepted (e.g., `Table | TableProviderExportable`)\n\n## Important Notes\n\n- The upstream DataFusion version used by this project is specified in `crates\u002Fcore\u002FCargo.toml` — check the `datafusion` dependency version to ensure you're comparing against the right upstream version.\n- Some upstream features may intentionally not be exposed (e.g., internal-only APIs). Use judgment about what's user-facing.\n- When fetching upstream docs, prefer the published docs.rs documentation as it matches the crate version.\n- Function aliases (e.g., `array_append` \u002F `list_append`) should both be exposed if upstream supports them.\n- Check the `__all__` list in `functions.py` to see what's publicly exported vs just defined.\n","\u003C!---\n  Licensed to the Apache Software Foundation (ASF) under one\n  or more contributor license agreements.  See the NOTICE file\n  distributed with this work for additional information\n  regarding copyright ownership.  The ASF licenses this file\n  to you under the Apache License, Version 2.0 (the\n  \"License\"); you may not use this file except in compliance\n  with the License.  You may obtain a copy of the License at\n\n    http:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing,\n  software distributed under the License is distributed on an\n  \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n  KIND, either express or implied.  See the License for the\n  specific language governing permissions and limitations\n  under the License.\n-->\n\n# Check Upstream DataFusion Feature Coverage\n\nYou are auditing the datafusion-python project to find features from the upstream Apache DataFusion Rust library that are **not yet exposed** in this Python binding project. Your goal is to identify gaps and, if asked, implement the missing bindings.\n\n**IMPORTANT: The Python API is the source of truth for coverage.** A function or method is considered \"exposed\" if it exists in the Python API (e.g., `python\u002Fdatafusion\u002Ffunctions.py`), even if there is no corresponding entry in the Rust bindings. Many upstream functions are aliases of other functions — the Python layer can expose these aliases by calling a different underlying Rust binding. Do NOT report a function as missing if it appears in the Python `__all__` list and has a working implementation, regardless of whether a matching `#[pyfunction]` exists in Rust.\n\n**IMPORTANT: audit the total upstream surface, not the delta since the last pin.** Gaps accumulate across syncs. A patch-release bump with a \"bug fixes only\" changelog does not mean there is nothing to find — pre-existing gaps from earlier majors still need to be surfaced. Always run the full comparison.\n\n## Compile-Signal Triggers\n\nIf a recent upstream bump required *any* of the following while fixing\ncompile errors in `crates\u002Fcore\u002F` or the FFI example, treat that as a\n**hard signal** that user-facing surface area grew and run this skill\nbefore considering the bump done. Each pattern corresponds to a class of\ngap that frequently shows up in the audit:\n\n| Signal during PR 1 compile fix | Likely gap to check |\n|---|---|\n| New `Expr::*` variant added to a non-exhaustive `match` (`HigherOrderFunction`, `Lambda`, `LambdaVariable`, …) | New lambda \u002F higher-order scalar functions (`any_match`, `array_transform`, `list_transform`, …) |\n| New `ScalarValue::*` variant (`ListView`, `LargeListView`, …) | New scalar \u002F array functions that consume or produce the type |\n| New required trait method on `ExecutionPlan` \u002F `TableProvider` \u002F `*UDFImpl` (`apply_expressions`, …) | Corresponding capability on the Python wrapper class |\n| Renamed or restructured struct field (e.g. `Cast.data_type` → `Cast.field: FieldRef`) | Any Python accessor \u002F SKILL.md doc that read the old field |\n| Newly deprecated trait method with a `_with_args` \u002F `_with_options` replacement | The `*_with_options` variant frequently warrants a separate Python entry point |\n\nPR 1 of `dev\u002Frelease\u002Fupstream-sync.md` asks you to log these signals as\nthey appear. When you run this skill, use that log as a checklist: every\nentry must either show up in the audit output or be explicitly skipped\nwith a reason.\n\n## Areas to Check\n\nThe user may specify an area via `$ARGUMENTS`. If no area is specified or \"all\" is given, check all areas.\n\n### 1. Scalar Functions\n\n**Upstream source of truth:**\n- Rust docs: https:\u002F\u002Fdocs.rs\u002Fdatafusion\u002Flatest\u002Fdatafusion\u002Ffunctions\u002Findex.html\n- User docs: https:\u002F\u002Fdatafusion.apache.org\u002Fuser-guide\u002Fsql\u002Fscalar_functions.html\n\n**Where they are exposed in this project:**\n- Python API: `python\u002Fdatafusion\u002Ffunctions.py` — each function wraps a call to `datafusion._internal.functions`\n- Rust bindings: `crates\u002Fcore\u002Fsrc\u002Ffunctions.rs` — `#[pyfunction]` definitions registered via `init_module()`\n\n**Evaluated and not requiring separate Python exposure:**\n- `get_field_path` — already covered by `get_field(expr, *names)`, which takes a\n  variadic field path and dispatches to the same underlying\n  `functions::core::get_field` UDF as the upstream `get_field_path` helper.\n\n**How to check:**\n1. Fetch the upstream scalar function documentation page\n2. Compare against functions listed in `python\u002Fdatafusion\u002Ffunctions.py` (check the `__all__` list and function definitions)\n3. A function is covered if it exists in the Python API — it does NOT need a dedicated Rust `#[pyfunction]`. Many functions are aliases that reuse another function's Rust binding.\n4. Check against the \"evaluated and not requiring exposure\" list before flagging as a gap\n5. Only report functions that are missing from the Python `__all__` list \u002F function definitions\n\n### 2. Aggregate Functions\n\n**Upstream source of truth:**\n- Rust docs: https:\u002F\u002Fdocs.rs\u002Fdatafusion\u002Flatest\u002Fdatafusion\u002Ffunctions_aggregate\u002Findex.html\n- User docs: https:\u002F\u002Fdatafusion.apache.org\u002Fuser-guide\u002Fsql\u002Faggregate_functions.html\n\n**Where they are exposed in this project:**\n- Python API: `python\u002Fdatafusion\u002Ffunctions.py` (aggregate functions are mixed in with scalar functions)\n- Rust bindings: `crates\u002Fcore\u002Fsrc\u002Ffunctions.rs`\n\n**Evaluated and not requiring separate Python exposure:**\n- `count_distinct` — covered by `count(expr, distinct=True)`. Both forms call\n  `count_udaf` with `distinct: bool = true` and produce the same logical plan.\n- `sum_distinct` — covered by `sum(expr, distinct=True)`.\n- `avg_distinct` — covered by `avg(expr, distinct=True)`.\n\n**How to check:**\n1. Fetch the upstream aggregate function documentation page\n2. Compare against aggregate functions in `python\u002Fdatafusion\u002Ffunctions.py` (check `__all__` list and function definitions)\n3. A function is covered if it exists in the Python API, even if it aliases another function's Rust binding\n4. Check against the \"evaluated and not requiring exposure\" list before flagging as a gap\n5. Report only functions missing from the Python API\n\n### 3. Window Functions\n\n**Upstream source of truth:**\n- Rust docs: https:\u002F\u002Fdocs.rs\u002Fdatafusion\u002Flatest\u002Fdatafusion\u002Ffunctions_window\u002Findex.html\n- User docs: https:\u002F\u002Fdatafusion.apache.org\u002Fuser-guide\u002Fsql\u002Fwindow_functions.html\n\n**Where they are exposed in this project:**\n- Python API: `python\u002Fdatafusion\u002Ffunctions.py` (window functions like `rank`, `dense_rank`, `lag`, `lead`, etc.)\n- Rust bindings: `crates\u002Fcore\u002Fsrc\u002Ffunctions.rs`\n\n**How to check:**\n1. Fetch the upstream window function documentation page\n2. Compare against window functions in `python\u002Fdatafusion\u002Ffunctions.py` (check `__all__` list and function definitions)\n3. A function is covered if it exists in the Python API, even if it aliases another function's Rust binding\n4. Report only functions missing from the Python API\n\n### 4. Table Functions\n\n**Upstream source of truth:**\n- Rust docs: https:\u002F\u002Fdocs.rs\u002Fdatafusion\u002Flatest\u002Fdatafusion\u002Ffunctions_table\u002Findex.html\n- User docs: https:\u002F\u002Fdatafusion.apache.org\u002Fuser-guide\u002Fsql\u002Ftable_functions.html (if available)\n\n**Where they are exposed in this project:**\n- Python API: `python\u002Fdatafusion\u002Ffunctions.py` and `python\u002Fdatafusion\u002Fuser_defined.py` (TableFunction\u002Fudtf)\n- Rust bindings: `crates\u002Fcore\u002Fsrc\u002Ffunctions.rs` and `crates\u002Fcore\u002Fsrc\u002Fudtf.rs`\n\n**How to check:**\n1. Fetch the upstream table function documentation\n2. Compare against what's available in the Python API\n3. A function is covered if it exists in the Python API, even if it aliases another function's Rust binding\n4. Report only functions missing from the Python API\n\n### 5. DataFrame Operations\n\n**Upstream source of truth:**\n- Rust docs: https:\u002F\u002Fdocs.rs\u002Fdatafusion\u002Flatest\u002Fdatafusion\u002Fdataframe\u002Fstruct.DataFrame.html\n\n**Where they are exposed in this project:**\n- Python API: `python\u002Fdatafusion\u002Fdataframe.py` — the `DataFrame` class\n- Rust bindings: `crates\u002Fcore\u002Fsrc\u002Fdataframe.rs` — `PyDataFrame` with `#[pymethods]`\n\n**Evaluated and not requiring separate Python exposure:**\n- `show_limit` — already covered by `DataFrame.show()`, which provides the same functionality with a simpler API\n- `with_param_values` — already covered by the `param_values` argument on `SessionContext.sql()`, which accomplishes the same thing more robustly\n- `union_by_name_distinct` — already covered by `DataFrame.union_by_name(distinct=True)`, which provides a more Pythonic API\n- `to_string` — `str(df)` is the Pythonic way to get a string and already goes through `__repr__` and the configurable formatter. A separate `to_string()` would either duplicate `str(df)` or render every row through a different path (session `datafusion.format.*` options, no formatter), giving a third text rendering alongside `repr` and `show()`\n\n**How to check:**\n1. Fetch the upstream DataFrame documentation page listing all methods\n2. Compare against methods in `python\u002Fdatafusion\u002Fdataframe.py` — this is the source of truth for coverage\n3. The Rust bindings (`crates\u002Fcore\u002Fsrc\u002Fdataframe.rs`) may be consulted for context, but a method is covered if it exists in the Python API\n4. Check against the \"evaluated and not requiring exposure\" list before flagging as a gap\n5. Report only methods missing from the Python API\n\n### 6. SessionContext Methods\n\n**Upstream source of truth:**\n- Rust docs: https:\u002F\u002Fdocs.rs\u002Fdatafusion\u002Flatest\u002Fdatafusion\u002Fexecution\u002Fcontext\u002Fstruct.SessionContext.html\n\n**Where they are exposed in this project:**\n- Python API: `python\u002Fdatafusion\u002Fcontext.py` — the `SessionContext` class\n- Rust bindings: `crates\u002Fcore\u002Fsrc\u002Fcontext.rs` — `PySessionContext` with `#[pymethods]`\n\n**How to check:**\n1. Fetch the upstream SessionContext documentation page listing all methods\n2. Compare against methods in `python\u002Fdatafusion\u002Fcontext.py` — this is the source of truth for coverage\n3. The Rust bindings (`crates\u002Fcore\u002Fsrc\u002Fcontext.rs`) may be consulted for context, but a method is covered if it exists in the Python API\n4. Report only methods missing from the Python API\n\n### 7. FFI Types (datafusion-ffi)\n\n**Upstream source of truth:**\n- Crate source: https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion\u002Ftree\u002Fmain\u002Fdatafusion\u002Fffi\u002Fsrc\n- Rust docs: https:\u002F\u002Fdocs.rs\u002Fdatafusion-ffi\u002Flatest\u002Fdatafusion_ffi\u002F\n\n**Where they are exposed in this project:**\n- Rust bindings: various files under `crates\u002Fcore\u002Fsrc\u002F` and `crates\u002Futil\u002Fsrc\u002F`\n- FFI example: `examples\u002Fdatafusion-ffi-example\u002Fsrc\u002F`\n- Dependency declared in root `Cargo.toml` and `crates\u002Fcore\u002FCargo.toml`\n\n**Discovering currently supported FFI types:**\nGrep for `use datafusion_ffi::` in `crates\u002Fcore\u002Fsrc\u002F` and `crates\u002Futil\u002Fsrc\u002F` to find all FFI types currently imported and used.\n\n**Evaluated and not requiring direct Python exposure:**\nThese upstream FFI types have been reviewed and do not need to be independently exposed to end users:\n- `FFI_ExecutionPlan` — already used indirectly through table providers; no need for direct exposure\n- `FFI_PhysicalExpr` \u002F `FFI_PhysicalSortExpr` — internal physical planning types not expected to be needed by end users\n- `FFI_RecordBatchStream` — one level deeper than FFI_ExecutionPlan, used internally when execution plans stream results\n- `FFI_SessionRef` \u002F `ForeignSession` — session sharing across FFI; Python manages sessions natively via SessionContext\n- `FFI_SessionConfig` — Python can configure sessions natively without FFI\n- `FFI_ConfigOptions` \u002F `FFI_TableOptions` — internal configuration plumbing\n- `FFI_PlanProperties` \u002F `FFI_Boundedness` \u002F `FFI_EmissionType` — read from existing plans, not user-facing\n- `FFI_Partitioning` — supporting type for physical planning\n- Supporting\u002Futility types (`FFI_Option`, `FFI_Result`, `WrappedSchema`, `WrappedArray`, `FFI_ColumnarValue`, `FFI_Volatility`, `FFI_InsertOp`, `FFI_AccumulatorArgs`, `FFI_Accumulator`, `FFI_GroupsAccumulator`, `FFI_EmitTo`, `FFI_AggregateOrderSensitivity`, `FFI_PartitionEvaluator`, `FFI_PartitionEvaluatorArgs`, `FFI_Range`, `FFI_SortOptions`, `FFI_Distribution`, `FFI_ExprProperties`, `FFI_SortProperties`, `FFI_Interval`, `FFI_TableProviderFilterPushDown`, `FFI_TableType`) — used as building blocks within the types above, not independently exposed\n\n**How to check:**\n1. Discover currently supported types by grepping for `use datafusion_ffi::` in `crates\u002Fcore\u002Fsrc\u002F` and `crates\u002Futil\u002Fsrc\u002F`, then compare against the upstream `datafusion-ffi` crate's `lib.rs` exports\n2. If new FFI types appear upstream, evaluate whether they represent a user-facing capability\n3. Check against the \"evaluated and not requiring exposure\" list before flagging as a gap\n4. Report any genuinely new types that enable user-facing functionality\n5. For each currently supported FFI type, verify the full pipeline is present using the checklist from \"Adding a New FFI Type\":\n   - Rust PyO3 wrapper with `from_pycapsule()` method\n   - Python Protocol type (e.g., `ScalarUDFExportable`) for FFI objects\n   - Python wrapper class with full type hints on all public methods\n   - ABC base class (if the type can be user-implemented)\n   - Registered in Rust `init_module()` and Python `__init__.py`\n   - FFI example in `examples\u002Fdatafusion-ffi-example\u002F`\n   - Type appears in union type hints where accepted\n\n### 8. Spark-Compatible Functions (`datafusion-spark` crate)\n\n**Upstream source of truth:**\n- Crate source: https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion\u002Ftree\u002Fmain\u002Fdatafusion\u002Fspark\u002Fsrc\n- Rust docs: https:\u002F\u002Fdocs.rs\u002Fdatafusion-spark\u002Flatest\u002Fdatafusion_spark\u002F\n\n**Where they are exposed in this project:**\n- Python API: `python\u002Fdatafusion\u002Ffunctions\u002Fspark.py` — each function wraps\n  a call to `datafusion._internal.functions.spark`; the public surface is\n  the module's `__all__` list.\n- Rust bindings: `crates\u002Fcore\u002Fsrc\u002Fspark_functions.rs` — `#[pyfunction]`\n  definitions registered via `init_module()` and re-exported under\n  `datafusion._internal.functions.spark`.\n\n**Coverage policy:** The spark namespace mirrors\n`pyspark.sql.functions` parameter names and shapes exactly so pyspark\ncallers can paste code unchanged. Extras over pyspark are permitted as\nlong as positional pyspark calls still work — for example, the spark\n`avg` \u002F `try_sum` \u002F `collect_list` \u002F `collect_set` retain the\n`distinct`\u002F`filter`\u002F`order_by`\u002F`null_treatment` kwargs from the main\nnamespace while pyspark's single-positional form continues to work.\n\n**How to check:**\n1. Fetch the upstream `datafusion-spark` function list from the crate\n   source under `datafusion\u002Fspark\u002Fsrc\u002Ffunction\u002F` (each subdirectory is a\n   category: `string\u002F`, `math\u002F`, `datetime\u002F`, etc.). The crate's\n   `function.rs` collects all `ScalarUDF` factories.\n2. Cross-reference against `pyspark.sql.functions` for the public-facing\n   shape — pyspark is the contract this namespace is matching.\n3. Compare against the functions listed in\n   `python\u002Fdatafusion\u002Ffunctions\u002Fspark.py`'s `__all__`. A function is\n   covered if it exists in the Python `spark` namespace, even if it\n   aliases another function's Rust binding.\n4. Report functions that are missing from the Python spark namespace.\n\n### 9. `__all__` Hygiene (functions.py and functions\u002Fspark.py)\n\nIndependent of upstream parity, also flag public `def` symbols in\n`python\u002Fdatafusion\u002Ffunctions.py` **and** `python\u002Fdatafusion\u002Ffunctions\u002Fspark.py`\nthat are missing from that file's `__all__`. These are functions a user\ncan call but that do not show up in\n`from datafusion.functions import *`, in tab-completion against the\nnamespace, or in generated API docs — typically an oversight rather than\nan intentional omission.\n\n**How to check:**\n1. Grep for `^def ([a-z_][a-z0-9_]*)\\(` in each file to enumerate every\n   public function definition.\n2. Read the `__all__` list at the top of the same file.\n3. Report any function in (1) that is not in (2). Skip private helpers\n   (names starting with `_`).\n\nA historical example: `instr` and `position` shipped as public `def`s but\nwere absent from `__all__` until the gap was caught here.\n\nFor each finding, propose adding the name to `__all__` in alphabetical\nposition with the existing entries.\n\n## Checking for Existing GitHub Issues\n\nAfter identifying missing APIs, search the open issues at https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-python\u002Fissues for each gap to see if an issue already exists requesting that API be exposed. Search using the function or method name as the query.\n\n- If an existing issue is found, include a link to it in the report. Do NOT create a new issue.\n- If no existing issue is found, note that no issue exists yet. If the user asks to create issues for missing APIs, each issue should specify that Python test coverage is required as part of the implementation.\n\n## Output Format\n\nFor each area checked, produce a report like:\n\n```\n## [Area Name] Coverage Report\n\n### Currently Exposed (X functions\u002Fmethods)\n- list of what's already available\n\n### Missing from Upstream (Y functions\u002Fmethods)\n- function_name — brief description of what it does (existing issue: #123)\n- function_name — brief description of what it does (no existing issue)\n\n### Notes\n- Any relevant observations about partial implementations, naming differences, etc.\n```\n\n## Implementation Pattern\n\nIf the user asks you to implement missing features, follow these patterns:\n\n### Adding a New Function (Scalar\u002FAggregate\u002FWindow)\n\n**Step 1: Rust binding** in `crates\u002Fcore\u002Fsrc\u002Ffunctions.rs`:\n```rust\n#[pyfunction]\n#[pyo3(signature = (arg1, arg2))]\nfn new_function_name(arg1: PyExpr, arg2: PyExpr) -> PyResult\u003CPyExpr> {\n    Ok(datafusion::functions::module::expr_fn::new_function_name(arg1.expr, arg2.expr).into())\n}\n```\nThen register in `init_module()`:\n```rust\nm.add_wrapped(wrap_pyfunction!(new_function_name))?;\n```\n\n**Step 2: Python wrapper** in `python\u002Fdatafusion\u002Ffunctions.py`:\n```python\ndef new_function_name(arg1: Expr, arg2: Expr) -> Expr:\n    \"\"\"Description of what the function does.\n\n    Args:\n        arg1: Description of first argument.\n        arg2: Description of second argument.\n\n    Returns:\n        Description of return value.\n    \"\"\"\n    return Expr(f.new_function_name(arg1.expr, arg2.expr))\n```\nAdd to `__all__` list.\n\n### Adding a New DataFrame Method\n\n**Step 1: Rust binding** in `crates\u002Fcore\u002Fsrc\u002Fdataframe.rs`:\n```rust\n#[pymethods]\nimpl PyDataFrame {\n    fn new_method(&self, py: Python, param: PyExpr) -> PyDataFusionResult\u003CSelf> {\n        let df = self.df.as_ref().clone().new_method(param.into())?;\n        Ok(Self::new(df))\n    }\n}\n```\n\n**Step 2: Python wrapper** in `python\u002Fdatafusion\u002Fdataframe.py`:\n```python\ndef new_method(self, param: Expr) -> DataFrame:\n    \"\"\"Description of the method.\"\"\"\n    return DataFrame(self.df.new_method(param.expr))\n```\n\n### Adding a New SessionContext Method\n\n**Step 1: Rust binding** in `crates\u002Fcore\u002Fsrc\u002Fcontext.rs`:\n```rust\n#[pymethods]\nimpl PySessionContext {\n    pub fn new_method(&self, py: Python, param: String) -> PyDataFusionResult\u003CPyDataFrame> {\n        let df = wait_for_future(py, self.ctx.new_method(&param))?;\n        Ok(PyDataFrame::new(df))\n    }\n}\n```\n\n**Step 2: Python wrapper** in `python\u002Fdatafusion\u002Fcontext.py`:\n```python\ndef new_method(self, param: str) -> DataFrame:\n    \"\"\"Description of the method.\"\"\"\n    return DataFrame(self.ctx.new_method(param))\n```\n\n### Adding a New FFI Type\n\nFFI types require a full pipeline from C struct through to a typed Python wrapper. Each layer must be present.\n\n**Step 1: Rust PyO3 wrapper class** in a new or existing file under `crates\u002Fcore\u002Fsrc\u002F`:\n```rust\nuse datafusion_ffi::new_type::FFI_NewType;\n\n#[pyclass(from_py_object, frozen, name = \"RawNewType\", module = \"datafusion.module_name\", subclass)]\npub struct PyNewType {\n    pub inner: Arc\u003Cdyn NewTypeTrait>,\n}\n\n#[pymethods]\nimpl PyNewType {\n    #[staticmethod]\n    fn from_pycapsule(obj: &Bound\u003C'_, PyAny>) -> PyDataFusionResult\u003CSelf> {\n        let capsule = obj\n            .getattr(\"__datafusion_new_type__\")?\n            .call0()?\n            .downcast::\u003CPyCapsule>()?;\n        let ffi_ptr = unsafe { capsule.reference::\u003CFFI_NewType>() };\n        let provider: Arc\u003Cdyn NewTypeTrait> = ffi_ptr.into();\n        Ok(Self { inner: provider })\n    }\n\n    fn some_method(&self) -> PyResult\u003C...> {\n        \u002F\u002F wrap inner trait method\n    }\n}\n```\nRegister in the appropriate `init_module()`:\n```rust\nm.add_class::\u003CPyNewType>()?;\n```\n\n**Step 2: Python Protocol type** in the appropriate Python module (e.g., `python\u002Fdatafusion\u002Fcatalog.py`):\n```python\nclass NewTypeExportable(Protocol):\n    \"\"\"Type hint for objects providing a __datafusion_new_type__ PyCapsule.\"\"\"\n\n    def __datafusion_new_type__(self) -> object: ...\n```\n\n**Step 3: Python wrapper class** in the same module:\n```python\nclass NewType:\n    \"\"\"Description of the type.\n\n    This class wraps a DataFusion NewType, which can be created from a native\n    Python implementation or imported from an FFI-compatible library.\n    \"\"\"\n\n    def __init__(\n        self,\n        new_type: df_internal.module_name.RawNewType | NewTypeExportable,\n    ) -> None:\n        if isinstance(new_type, df_internal.module_name.RawNewType):\n            self._raw = new_type\n        else:\n            self._raw = df_internal.module_name.RawNewType.from_pycapsule(new_type)\n\n    def some_method(self) -> ReturnType:\n        \"\"\"Description of the method.\"\"\"\n        return self._raw.some_method()\n```\n\n**Step 4: ABC base class** (if users should be able to subclass and provide custom implementations in Python):\n```python\nfrom abc import ABC, abstractmethod\n\nclass NewTypeProvider(ABC):\n    \"\"\"Abstract base class for implementing a custom NewType in Python.\"\"\"\n\n    @abstractmethod\n    def some_method(self) -> ReturnType:\n        \"\"\"Description of the method.\"\"\"\n        ...\n```\n\n**Step 5: Module exports** — add to the appropriate `__init__.py`:\n- Add the wrapper class (`NewType`) to `python\u002Fdatafusion\u002F__init__.py`\n- Add the ABC (`NewTypeProvider`) if applicable\n- Add the Protocol type (`NewTypeExportable`) if it should be public\n\n**Step 6: FFI example** — add an example implementation under `examples\u002Fdatafusion-ffi-example\u002Fsrc\u002F`:\n```rust\n\u002F\u002F examples\u002Fdatafusion-ffi-example\u002Fsrc\u002Fnew_type.rs\nuse datafusion_ffi::new_type::FFI_NewType;\n\u002F\u002F ... example showing how an external Rust library exposes this type via PyCapsule\n```\n\n**Checklist for each FFI type:**\n- [ ] Rust PyO3 wrapper with `from_pycapsule()` method\n- [ ] Python Protocol type (e.g., `NewTypeExportable`) for FFI objects\n- [ ] Python wrapper class with full type hints on all public methods\n- [ ] ABC base class (if the type can be user-implemented)\n- [ ] Registered in Rust `init_module()` and Python `__init__.py`\n- [ ] FFI example in `examples\u002Fdatafusion-ffi-example\u002F`\n- [ ] Type appears in union type hints where accepted (e.g., `Table | TableProviderExportable`)\n\n## Important Notes\n\n- The upstream DataFusion version used by this project is specified in `crates\u002Fcore\u002FCargo.toml` — check the `datafusion` dependency version to ensure you're comparing against the right upstream version.\n- Some upstream features may intentionally not be exposed (e.g., internal-only APIs). Use judgment about what's user-facing.\n- When fetching upstream docs, prefer the published docs.rs documentation as it matches the crate version.\n- Function aliases (e.g., `array_append` \u002F `list_append`) should both be exposed if upstream supports them.\n- Check the `__all__` list in `functions.py` to see what's publicly exported vs just defined.\n",{},"main","878e5d3b8d373bca19671af43e49dfb1890f8da2",".ai\u002Fskills\u002Fcheck-upstream",184,"https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-python","https:\u002F\u002Fdatafusion.apache.org\u002Fpython","https:\u002F\u002Fgithub.com\u002Fapache","https:\u002F\u002Fwww.apache.org\u002F","2026-11-09 03:42:43",{"source":9,"skillName":5,"commands":46,"prompt":56,"zipAvailable":57},[47,50,53],{"tool":48,"command":49},"npx","npx skills add apache\u002Fdatafusion-python --skill check-upstream",{"tool":51,"command":52},"bunx","bunx skills add apache\u002Fdatafusion-python --skill check-upstream",{"tool":54,"command":55},"pnpm","pnpm dlx skills add apache\u002Fdatafusion-python --skill check-upstream","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-python\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Fcheck-upstream\u002FSKILL.md",true,[59,65,71,75,79],{"path":60,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":63,"sourceHtmlUrl":64},"references\u002Fagent-philosophy.md","REFERENCE","参考文档",8030,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fagent-builder\u002Freferences\u002Fagent-philosophy.md",{"path":66,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":69,"sourceHtmlUrl":70},"references\u002Fminimal-agent.py","SCRIPT","脚本",4148,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fagent-builder\u002Freferences\u002Fminimal-agent.py",{"path":72,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Fsubagent-pattern.py",7773,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fagent-builder\u002Freferences\u002Fsubagent-pattern.py",{"path":76,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Ftool-templates.py",7881,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fagent-builder\u002Freferences\u002Ftool-templates.py",{"path":80,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":81,"sourceHtmlUrl":82},"scripts\u002Finit_agent.py",9933,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fagent-builder\u002Fscripts\u002Finit_agent.py",[84,107,119,136],{"skillNo":85,"name":86,"nameZh":87,"description":88,"descriptionZh":89,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":90,"categories":91,"keywords":98,"publishedAt":31},"01M6ACM3GXZHMNHNE4DHDBBXVK","datafusion-python","DataFusion Python 开发","Use when the user is writing datafusion-python (Apache DataFusion Python bindings) DataFrame or SQL code. Covers imports, data loading, DataFrame operations, expression building, SQL-to-DataFrame mappings, idiomatic patterns, and common pitfalls.","当用户编写 datafusion-python（Apache DataFusion 的 Python 绑定）DataFrame 或 SQL 代码时使用。涵盖导入、数据加载、DataFrame 操作、表达式构建、SQL 到 DataFrame 的映射、惯用写法及常见陷阱。","https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-python\u002Fblob\u002Fmain\u002Fskills\u002Fdatafusion_python\u002FSKILL.md",[92,95],{"categoryNo":93,"categoryName":94,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BQGD4CMBM6B4PWSM1NXGT9","数据分析与报告",{"categoryNo":96,"categoryName":97,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BTGTEHKD89NSZ5CT4Y5AGV","数据工程师",[99,100,101,102,103,10,104,105,106],"datafusion python","datafusion","python","writing","dataframe","data loading","code","sql",{"skillNo":108,"name":109,"nameZh":110,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":111,"categories":112,"keywords":117,"publishedAt":31},"01M6ACM17FMWAHVBVMWQZ816NF","make-pythonic","Python 代码风格优化","https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-python\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Fmake-pythonic\u002FSKILL.md",[113,114],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},{"categoryNo":115,"categoryName":116,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BT7QVANT4709358VEJK53E","代码实现",[118],"make pythonic",{"skillNo":120,"name":121,"nameZh":122,"description":123,"descriptionZh":124,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":125,"categories":126,"keywords":131,"publishedAt":31},"01M6ACKZ12QZPH2YSN7ENQW13J","ffi-capsule-protocol","DataFusion FFI 胶囊协议","TRIGGER — read before adding, changing, or reviewing any __datafusion_*__ capsule getter, any FFI_* export that asks for a TaskContextProvider or an extension codec, or any code that calls FFI_QueryPlanner::new \u002F FFI_TableProvider::new \u002F FFI_{Logical,Physical}ExtensionCodec::new. These methods are one protocol with a settled convention. Do not design it fresh; do not construct a SessionContext inside an extension library.","触发式技能——在添加、修改或审查任何 __datafusion_*__ capsule getter、任何请求 TaskContextProvider 或扩展编解码器的 FFI_* 导出，或任何调用 FFI_QueryPlanner::new \u002F FFI_TableProvider::new \u002F FFI_{Logical,Physical}ExtensionCodec::new 的代码之前，请先阅读本技能。这些方法属于同一套已有既定约定的协议。不要重新设计，也不要在扩展库内部构造 SessionContext。","https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-python\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Fffi-capsule-protocol\u002FSKILL.md",[127,128],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},{"categoryNo":129,"categoryName":130,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BSNPHVX9Y1H3B2ZX3V06RF","Rust 开发",[132,133,100,105,134,135],"protocol","ffi capsule protocol","review","design",{"skillNo":137,"name":138,"nameZh":139,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":140,"categories":141,"keywords":146,"publishedAt":31},"01M6ACKVJSNMT7YDTXEFJNZMY3","audit-skill-md","SKILL.md 技能文档审计","https:\u002F\u002Fgithub.com\u002Fapache\u002Fdatafusion-python\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Faudit-skill-md\u002FSKILL.md",[142,143],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},{"categoryNo":144,"categoryName":145,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BRN0CV1NMDZ5TEJX1GVM29","插件与技能管理",[147],"audit skill md"]