Skip to content

Commit 923f7d9

Browse files
authored
Merge branch 'main' into add_date_functions
2 parents 9343a73 + b48076a commit 923f7d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+858
-665
lines changed

.github/copilot-instructions.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1-
# GitHub Copilot Instructions for dm Package
1+
# GitHub Copilot Instructions for duckdb Package
22

33
Read and follow the development guidelines outlined in [CLAUDE.md](../CLAUDE.md).
4+
5+
## Working Effectively
6+
7+
### Bootstrap, Build, and Test the Repository
8+
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+
### Format Checking (Optional - Has Known Issues)
20+
21+
- `pip3 install cmake-format && export PATH="$HOME/.local/bin:$PATH"` -- installs formatter
22+
- `make format-check` -- checks code formatting

CLAUDE.md

Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,65 @@
22

33
R package that contains a vendored copy of the DuckDB C++ library and glue code for R, including a DBI and a relational interface.
44

5-
## Package layout
5+
## Working Effectively
66

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
118

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
1364

1465
```bash
1566
# From the duckdb-r directory
@@ -42,3 +93,25 @@ R
4293
- Test files located in `tests/testthat/`
4394
- Use `testthat::test_local(filter = "name")` for running specific test files
4495
- 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

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: duckdb
22
Title: DBI Package for the DuckDB Database Management System
3-
Version: 1.3.2.9020
3+
Version: 1.3.2.9021
44
Authors@R: c(
55
person("Hannes", "Mühleisen", , "[email protected]", role = "aut",
66
comment = c(ORCID = "0000-0001-8552-0029")),

NEWS.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
<!-- NEWS.md is maintained by https://fledge.cynkra.com, contributors should not edit this file -->
22

3+
# duckdb 1.3.2.9021
4+
5+
## Bug fixes
6+
7+
- Fix timezone conversion for invalid timestamps with `tz_out_convert = "force"`.
8+
9+
- Substitute invalid UTF-8 characters in error messages to avoid a failure when reporting the error.
10+
11+
- Fix index calculation for retrieval of arrays (#1473).
12+
13+
## Features
14+
15+
- `dbGetInfo()` gets the version from a hard-coded value and not from a DuckDB query.
16+
17+
- Package uses two cores by default for compilation.
18+
19+
## Chore
20+
21+
- Add AI instructions.
22+
23+
- Build-ignore.
24+
25+
- Add Claude instructions.
26+
27+
## Testing
28+
29+
- Add `local_con()` test fixture for cleaner DuckDB connection management.
30+
31+
332
# duckdb 1.3.2.9020
433

534
## Continuous integration

R/Result.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,5 @@ tz_force_one <- function(x, timezone) {
119119
# convert to character in ISO format, stripping the timezone
120120
ct <- format(x, format = "%Y-%m-%d %H:%M:%OS", usetz = FALSE)
121121
# recreate the POSIXct with specified timezone
122-
as.POSIXct(ct, tz = timezone)
122+
as.POSIXct(ct, format = "%Y-%m-%d %H:%M:%OS", tz = timezone)
123123
}

R/dbGetInfo__duckdb_connection.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#' @param dbObj An object inheriting from class [duckdb_connection-class].
44
#' @usage NULL
55
dbGetInfo__duckdb_connection <- function(dbObj, ...) {
6-
version <- dbGetQuery(dbObj, "select library_version from pragma_version()")[[1]][[1]]
6+
# Use hard-coded version instead of querying database to avoid establishing connection
7+
version <- get_duckdb_version()
78

89
list(
910
dbname = dbObj@driver@dbdir,

R/rethrow.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,13 @@ rethrow_error_from_rapi <- function(e, call) {
66
# the caller.
77

88
msg <- conditionMessage(e)
9+
tryCatch(
10+
# Called for side effect, rlang::abort() eventually calls nchar()
11+
nchar(msg),
12+
error = function(e) {
13+
msg <<- iconv(msg, from = "UTF-8", to = "UTF-8", sub = "?")
14+
}
15+
)
16+
917
rlang::abort(msg, call = call)
1018
}

R/test-fixtures.R

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#' Local DuckDB connection fixture for testing
2+
#'
3+
#' Creates a DuckDB connection that will be automatically disconnected
4+
#' when the calling function exits. This is a test fixture that follows
5+
#' testthat guidelines for resource management.
6+
#'
7+
#' @param ... Additional arguments passed to [duckdb()]
8+
#'
9+
#' @return A DuckDB connection object
10+
#' @noRd
11+
#'
12+
#' @examples
13+
#' \dontrun{
14+
#' # In a test
15+
#' test_that("my test", {
16+
#' con <- local_con()
17+
#' # Use the connection...
18+
#' # It will be automatically disconnected when the test exits
19+
#' })
20+
#' }
21+
local_con <- function(..., drv = duckdb()) {
22+
con <- dbConnect(drv, ...)
23+
withr::defer_parent(dbDisconnect(con, shutdown = TRUE))
24+
con
25+
}

R/version.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Generated by rconfigure.py, do not edit by hand
2+
# DuckDB version information
3+
4+
duckdb_version <- "1.3.3-dev231"
5+
6+
# Function to get DuckDB version without establishing a connection
7+
get_duckdb_version <- function() {
8+
duckdb_version
9+
}

configure

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
set -ex
44

5+
# Setup parallel compilation if MAKEFLAGS not already set
6+
cd "$(dirname "$0")"
7+
if [ -z "${MAKEFLAGS}" ]; then
8+
makeflags_value=$(Rscript scripts/setup-makeflags.R 2>/dev/null || echo "")
9+
if [ -n "${makeflags_value}" ]; then
10+
export MAKEFLAGS="${makeflags_value}"
11+
echo "Setting MAKEFLAGS=${makeflags_value} for parallel compilation"
12+
echo "Set NOT_CRAN or MAKEFLAGS to override"
13+
fi
14+
else
15+
echo "MAKEFLAGS already set to: ${MAKEFLAGS}"
16+
fi
17+
518
cd "$(dirname "$0")/src"
619

720
# Not used on Linux, for completeness.

0 commit comments

Comments
 (0)