|
2 | 2 |
|
3 | 3 | R package that contains a vendored copy of the DuckDB C++ library and glue code for R, including a DBI and a relational interface. |
4 | 4 |
|
5 | | -## Package layout |
| 5 | +## Working Effectively |
6 | 6 |
|
7 | | -- `R/`: R scripts and package code |
8 | | -- `src/*.cpp`: C++ glue |
9 | | -- `src/duckdb/`: C++ source code for DuckDB, can be reviewed but only modified in rare cases |
10 | | -- `tests/`: Unit tests for the package |
| 7 | +### Bootstrap, Build, and Test the Repository |
11 | 8 |
|
12 | | -## Compilation |
| 9 | +- `sudo apt-get install -y r-base r-base-dev build-essential` -- installs R and development tools |
| 10 | +- `mkdir -p ~/R/library && echo '.libPaths("~/R/library")' > ~/.Rprofile` -- sets up local R library |
| 11 | +- `export MAKEFLAGS="-j$(nproc)"` -- enables parallel compilation |
| 12 | +- `UserNM=true R CMD INSTALL . --no-byte-compile` -- builds and installs the package. NEVER CANCEL: takes 10-15 minutes on first build. Set timeout to 30+ minutes. |
| 13 | + |
| 14 | +### Run Tests |
| 15 | + |
| 16 | +- `R -q -e "testthat::test_local()"` -- runs all tests. Takes about 45 seconds. NEVER CANCEL: set timeout to 5+ minutes. |
| 17 | +- `R -q -e "testthat::test_local(filter = '^name$')"` -- runs specific test file by name |
| 18 | + |
| 19 | +### Manual Validation |
| 20 | + |
| 21 | +- ALWAYS test basic DuckDB functionality after making changes by running a complete scenario |
| 22 | +- Test connection, table creation, data insertion, and querying: |
| 23 | + |
| 24 | + ```r |
| 25 | + library(duckdb) |
| 26 | + con <- dbConnect(duckdb()) |
| 27 | + dbExecute(con, "CREATE TABLE test (id INTEGER, name VARCHAR)") |
| 28 | + dbExecute(con, "INSERT INTO test VALUES (1, 'Alice'), (2, 'Bob')") |
| 29 | + result <- dbGetQuery(con, "SELECT * FROM test ORDER BY id") |
| 30 | + print(result) |
| 31 | + dbDisconnect(con, shutdown=TRUE) |
| 32 | + ``` |
| 33 | + |
| 34 | +### Format Checking (Optional - Has Known Issues) |
| 35 | + |
| 36 | +- `pip3 install cmake-format && export PATH="$HOME/.local/bin:$PATH"` -- installs formatter |
| 37 | +- `make format-check` -- checks code formatting (currently shows formatting differences) |
| 38 | + |
| 39 | +## Validation |
| 40 | + |
| 41 | +- ALWAYS run through a complete end-to-end scenario after making changes to ensure DuckDB R package functionality works correctly. |
| 42 | +- The package can be built and tested successfully, though some formatting issues exist in the current codebase. |
| 43 | +- One test failure is expected in clock function tests (unrelated to core functionality). |
| 44 | +- Format checking will show differences but should not block development. |
| 45 | + |
| 46 | +## Repository Structure and Key Locations |
| 47 | + |
| 48 | +- `R/`: R source code (17 files) - DBI interface, connection handling, result processing |
| 49 | +- `src/*.cpp`: C++ glue code (~30 files) - R to DuckDB interface |
| 50 | +- `src/duckdb/`: Vendored DuckDB C++ source code (~1700 C++ files, ~1400 headers) - DO NOT modify except in rare cases |
| 51 | +- `tests/testthat/`: Unit tests (~40 test files) - comprehensive test coverage |
| 52 | +- `scripts/`: Build and maintenance scripts - vendor.sh, format.py, setup-makeflags.R |
| 53 | +- `configure`/`configure.win`: Build configuration scripts |
| 54 | +- `DESCRIPTION`: R package metadata and dependencies |
| 55 | +- `README.md`: Main documentation with build instructions |
| 56 | +- `CLAUDE.md`: Operational instructions for AI |
| 57 | +- `.github/workflows/`: CI/CD workflows for testing on multiple platforms |
| 58 | + |
| 59 | +## Common Tasks |
| 60 | + |
| 61 | +The following are validated commands and their typical execution times: |
| 62 | + |
| 63 | +### Building |
13 | 64 |
|
14 | 65 | ```bash |
15 | 66 | # From the duckdb-r directory |
|
42 | 93 | - Test files located in `tests/testthat/` |
43 | 94 | - Use `testthat::test_local(filter = "name")` for running specific test files |
44 | 95 | - Always add tests when fixing bugs to prevent regression |
| 96 | + |
| 97 | +## Code Style Guidelines |
| 98 | + |
| 99 | +- All files must end with an end-of-line (EOL) character |
| 100 | +- Ensure proper code formatting and consistent indentation |
| 101 | +- Follow R package development best practices |
| 102 | + |
| 103 | +## Dependencies |
| 104 | + |
| 105 | +System requirements already satisfied in typical development environment: |
| 106 | +- R >= 4.1.0 |
| 107 | +- build-essential (gcc, g++, make) |
| 108 | +- Standard R packages: DBI, testthat, methods, utils |
| 109 | +- Optional: cmake-format for code formatting |
| 110 | + |
| 111 | +## Package Information |
| 112 | + |
| 113 | +- **Package Type**: R package providing DBI interface to DuckDB |
| 114 | +- **Core Functionality**: In-process SQL OLAP database for R |
| 115 | +- **Installation Time**: Up to 60 minutes from source (mentioned in README) |
| 116 | +- **Build Architecture**: C++ database engine with R bindings |
| 117 | +- **Key Features**: DBI compliance, Arrow integration, analytical query performance |
0 commit comments