ThinkR-open / ThinkR-open/datadiff
[bug] Chemin lazy : une colonne utilisateur nommée « n » fausse find_duplicate_keys() et casse lazy_nrow()
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 6
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Contexte
Deux helpers lazy utilisent dplyr::count() sans nom de colonne réservé. Quand la table contient déjà une colonne n, count() nomme son compte nn (comportement documenté de count/tally) :
find_duplicate_keys()(R/duplicate_keys.R:25-28) :count(across(all_of(key))) %>% filter(n > 1L)— si la clé s'appellen, lefilter(n > 1L)filtre les valeurs de la clé au lieu du compte → détection de doublons silencieusement fausse, etsum(dups$n)additionne les valeurs de clé dans le message d'avertissement.lazy_nrow()(R/validation.R:1-7) :pull(collect(count(x)), n)— si la table a une colonnen, le compte s'appellenn→pull(..., n)erreur « column n doesn't exist » (appelé systématiquement parvalidate_row_counts(), donc toute comparaison lazy d'une table avec une colonnenéchoue).
globalVariables("n") (R/globals.R) masque la NOTE R CMD check mais pas ces collisions.
Reprex
library(datadiff); library(duckdb); library(dplyr)
ref <- data.frame(n = c(1, 1, 2), v = c(10, 10, 20)) # colonne nommée "n"
cand <- ref
con <- dbConnect(duckdb())
duckdb_register(con, "ref", ref); duckdb_register(con, "cand", cand)
# lazy_nrow -> count() nomme le compte "nn" -> pull(n) échoue
compare_datasets_from_yaml(tbl(con, "ref"), tbl(con, "cand"), key = "n")
#> Error ... column `n` doesn't exist (ou détection de doublons faussée selon le chemin)
Critères de succès
-
count()/tally()appelés avecname = "..datadiff_n"(ou équivalent réservé) dansfind_duplicate_keys()etlazy_nrow(); lefilter()et les agrégats référencent ce nom. - Le reprex fonctionne : comparaison lazy correcte d'une table avec colonne
n, y compris clé nomméenavec vrais doublons (warning aux bons comptes). - Tests DuckDB : (a) table avec colonne
nnon-clé ; (b) clé nomméenavec doublons ; (c)sum()du warning sur backend renvoyant integer64. -
globalVariables("n")supprimé si plus nécessaire.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with R/duplicate_keys.R and R/validation.R, then reproduce the issue using the DuckDB example in the report. Add DuckDB coverage for a non-key column named n, a key named n with duplicates, and integer64 warning counts. Done means lazy comparisons use the reserved count name correctly and globalVariables("n") is removed if no longer needed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 75/100