Skip to content

Commit 3fc4cf4

Browse files
committed
Document Cargo features
[skip ci]
1 parent 8158c7c commit 3fc4cf4

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

README.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,38 @@ fn main() -> Result<()> {
7777
}
7878
```
7979

80+
## Feature flags
81+
82+
The `duckdb` crate provides a number of Cargo features that can be enabled to add functionality:
83+
84+
### Virtual tables and functions
85+
86+
- `vtab` - Base support for creating custom table functions and virtual tables.
87+
- `vtab-arrow` - Apache Arrow integration for virtual tables. Enables conversion between Arrow RecordBatch and DuckDB data chunks.
88+
- `vtab-excel` - Read Excel (.xlsx) files directly in SQL queries with automatic schema detection.
89+
- `vtab-loadable` - Support for creating loadable DuckDB extensions. Includes procedural macros for extension development.
90+
- `vscalar` - Create custom scalar functions that operate on individual values or rows.
91+
- `vscalar-arrow` - Arrow-optimized scalar functions for vectorized operations.
92+
93+
### Data integration
94+
95+
- `json` - Enables reading and writing JSON files. Requires `bundled`.
96+
- `parquet` - Enables reading and writing Parquet files. Requires `bundled`.
97+
- `appender-arrow` - Efficient bulk insertion of Arrow data into DuckDB tables.
98+
- `polars` - Integration with Polars DataFrames.
99+
100+
### Convenience features
101+
102+
- `vtab-full` - Enables all virtual table features: `vtab-excel`, `vtab-arrow`, and `appender-arrow`.
103+
- `extensions-full` - Enables all major extensions: `json`, `parquet`, and `vtab-full`.
104+
- `modern-full` - Enables modern Rust ecosystem integrations: `chrono`, `serde_json`, `url`, `r2d2`, `uuid`, and `polars`.
105+
106+
### Build configuration
107+
108+
- `bundled` - Uses a bundled version of DuckDB's source code and compiles it during build. This is the simplest way to get started and avoids needing DuckDB system libraries.
109+
- `buildtime_bindgen` - Use bindgen at build time to generate fresh bindings instead of using pre-generated ones.
110+
- `loadable-extension` - _Experimental_ support for building extensions that can be dynamically loaded into DuckDB.
111+
80112
## Notes on building duckdb and libduckdb-sys
81113

82114
`libduckdb-sys` is a separate crate from `duckdb-rs` that provides the Rust
@@ -103,7 +135,8 @@ You can adjust this behavior in a number of ways:
103135
# Assume that version DuckDB version 0.9.2 is used.
104136
duckdb = { version = "0.9.2", features = ["bundled"] }
105137
```
106-
* When linking against a DuckDB library already on the system (so *not* using any of the `bundled` features), you can set the `DUCKDB_LIB_DIR` environment variable to point to a directory containing the library. You can also set the `DUCKDB_INCLUDE_DIR` variable to point to the directory containing `duckdb.h`.
138+
139+
* When linking against a DuckDB library already on the system (so _not_ using any of the `bundled` features), you can set the `DUCKDB_LIB_DIR` environment variable to point to a directory containing the library. You can also set the `DUCKDB_INCLUDE_DIR` variable to point to the directory containing `duckdb.h`.
107140
* Installing the duckdb development packages will usually be all that is required, but
108141
the build helpers for [pkg-config](https://github.com/alexcrichton/pkg-config-rs)
109142
and [vcpkg](https://github.com/mcgoo/vcpkg-rs) have some additional configuration
@@ -118,11 +151,11 @@ declarations from DuckDB's C header file. `bindgen`
118151
running this as part of the build process of libraries that used this. We tried
119152
this briefly (`duckdb` 0.10.0, specifically), but it had some annoyances:
120153

121-
* The build time for `libduckdb-sys` (and therefore `duckdb`) increased
154+
- The build time for `libduckdb-sys` (and therefore `duckdb`) increased
122155
dramatically.
123-
* Running `bindgen` requires a relatively-recent version of Clang, which many
156+
- Running `bindgen` requires a relatively-recent version of Clang, which many
124157
systems do not have installed by default.
125-
* Running `bindgen` also requires the DuckDB header file to be present.
158+
- Running `bindgen` also requires the DuckDB header file to be present.
126159

127160
So we try to avoid running `bindgen` at build-time by shipping
128161
pregenerated bindings for DuckDB.

0 commit comments

Comments
 (0)