Skip to content

Commit 2bd8391

Browse files
committed
feat: enhance Copilot instructions with detailed project architecture and development workflows
1 parent 6dd5cf7 commit 2bd8391

1 file changed

Lines changed: 38 additions & 2 deletions

File tree

.github/copilot-instructions.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
# Copilot Instructions
1+
# Copilot Instructions for datafusion-python
2+
3+
## Project Architecture
4+
5+
- **Core Engine:** Rust (`src/`) implements the main logic using Apache Arrow DataFusion.
6+
- **Python Bindings:** Exposed via PyO3 (`src/`, `python/datafusion/`), with high-level Python APIs wrapping Rust internals.
7+
- **Data Flow:** Python API → PyO3 FFI → DataFusion Core (Rust) → PyArrow for data exchange.
8+
- **Key Entry Points:** `SessionContext` (`context.py`), `DataFrame` (`dataframe.py`), UDF/UDAF/UDWF registration.
9+
10+
## Development Workflows
11+
12+
- **Build & Install:** Use `maturin develop` (optionally with `--uv`) to build Rust and install the Python extension.
13+
- **Testing:** Run `pytest` in the root or `python/tests/` for Python tests. Rust code is tested via `cargo test`.
14+
- **Linting:** Use `ruff` for Python (`./ci/scripts/python_lint.sh`), `rustfmt` and `clippy` for Rust (`./ci/scripts/rust_fmt.sh`, `./ci/scripts/rust_clippy.sh`).
15+
- **Pre-commit:** Install with `pre-commit install` and run checks before pushing.
216

317
## Python Code Style
418

@@ -38,6 +52,26 @@ When generating Python code for the DataFusion Python project, adhere to the fol
3852
- Group related tests in classes
3953
- Use pytest style assertions instead of unittest style
4054

55+
## Patterns & Examples
56+
57+
- **SessionContext**: Central object for query execution. See `examples/create-context.py`.
58+
- **DataFrame**: Immutable, chainable API for query building. See `examples/dataframe-parquet.py`.
59+
- **UDF/UDAF/UDWF**: Register Python functions for use in SQL/DataFrame queries. See `examples/python-udf.py`, `examples/python-udaf.py`.
60+
- **PyArrow**: Used for all data interchange; prefer Arrow types in UDFs and DataFrame construction.
61+
62+
## External Dependencies
63+
64+
- **Build:** maturin, PyO3, uv/pip, pytest, ruff, rustfmt, clippy
65+
- **Data:** Example datasets in `docs/` and referenced in `examples/`
66+
67+
## Directory Structure
68+
69+
- `src/`: Rust core and FFI
70+
- `python/datafusion/`: Python API
71+
- `python/tests/`: Python tests
72+
- `examples/`: Usage examples
73+
- `ci/scripts/`: Lint/build scripts
74+
4175
## Rust Code Style
4276

4377
When generating Rust code for DataFusion, follow these guidelines:
@@ -47,7 +81,9 @@ When generating Rust code for DataFusion, follow these guidelines:
4781
- Correct: `if some_condition`
4882
- Incorrect: `if (some_condition)`
4983

50-
2. Follow the standard Rust style conventions from rustfmt
84+
2. Avoid `expect()` or `panic!()` except in tests - use proper error handling with `Result` types
85+
86+
3. Follow the standard Rust style conventions from rustfmt
5187

5288
### Code Organization
5389

0 commit comments

Comments
 (0)