|
19 | 19 |
|
20 | 20 | # API health policy
|
21 | 21 |
|
22 |
| -To maintain API health, developers must track and properly deprecate outdated methods. |
| 22 | +DataFusion is used extensively as a library and has a large public API, thus it |
| 23 | +is important that the API is well maintained. In general, we try to minimize |
| 24 | +breaking API changes, but they are sometimes necessary. |
| 25 | + |
| 26 | +When possible, rather than making breaking API changes, we prefer to deprecate |
| 27 | +APIs to give users time to adjust to the changes. |
| 28 | + |
| 29 | +## Breaking Changes |
| 30 | + |
| 31 | +In general, a function is part of the public API if it appears on the [docs.rs page] |
| 32 | + |
| 33 | +Breaking public API changes are those that _require_ users to change their code |
| 34 | +for it to compile, and are listed as "Major Changes" in the [SemVer |
| 35 | +Compatibility Section of the cargo book]. Common examples of breaking changes: |
| 36 | + |
| 37 | +- Adding new required parameters to a function (`foo(a: i32, b: i32)` -> `foo(a: i32, b: i32, c: i32)`) |
| 38 | +- Removing a `pub` function |
| 39 | +- Changing the return type of a function |
| 40 | + |
| 41 | +When making breaking public API changes, please add the `api-change` label to |
| 42 | +the PR so we can highlight the changes in the release notes. |
| 43 | + |
| 44 | +[docs.rs page]: https://docs.rs/datafusion/latest/datafusion/index.html |
| 45 | +[semver compatibility section of the cargo book]: https://doc.rust-lang.org/cargo/reference/semver.html#change-categories |
| 46 | + |
| 47 | +## Deprecation Guidelines |
| 48 | + |
23 | 49 | When deprecating a method:
|
24 | 50 |
|
25 |
| -- clearly mark the API as deprecated and specify the exact DataFusion version in which it was deprecated. |
26 |
| -- concisely describe the preferred API, if relevant |
| 51 | +- Mark the API as deprecated using `#[deprecated]` and specify the exact DataFusion version in which it was deprecated |
| 52 | +- Concisely describe the preferred API to help the user transition |
| 53 | + |
| 54 | +The deprecated version is the next version which contains the deprecation. For |
| 55 | +example, if the current version listed in [`Cargo.toml`] is `43.0.0` then the next |
| 56 | +version will be `44.0.0`. |
| 57 | + |
| 58 | +[`cargo.toml`]: https://github.com/apache/datafusion/blob/main/Cargo.toml |
| 59 | + |
| 60 | +To mark the API as deprecated, use the `#[deprecated]` attribute like this: |
| 61 | + |
| 62 | +```rust |
| 63 | + #[deprecated(since = "...", note = "...")] |
| 64 | +``` |
27 | 65 |
|
28 |
| -API deprecation example: |
| 66 | +For example: |
29 | 67 |
|
30 | 68 | ```rust
|
31 | 69 | #[deprecated(since = "41.0.0", note = "Use SessionStateBuilder")]
|
|
0 commit comments