ThinkR-open / ThinkR-open/datadiff

[bug] Chemin lazy : une colonne utilisateur nommée « n » fausse find_duplicate_keys() et casse lazy_nrow()

Open
#18 0 comments 0 reactions 0 assignees View on GitHub

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) :

  1. find_duplicate_keys() (R/duplicate_keys.R:25-28) : count(across(all_of(key))) %>% filter(n > 1L) — si la clé s'appelle n, le filter(n > 1L) filtre les valeurs de la clé au lieu du compte → détection de doublons silencieusement fausse, et sum(dups$n) additionne les valeurs de clé dans le message d'avertissement.
  2. lazy_nrow() (R/validation.R:1-7) : pull(collect(count(x)), n) — si la table a une colonne n, le compte s'appelle nnpull(..., n) erreur « column n doesn't exist » (appelé systématiquement par validate_row_counts(), donc toute comparaison lazy d'une table avec une colonne n é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 avec name = "..datadiff_n" (ou équivalent réservé) dans find_duplicate_keys() et lazy_nrow() ; le filter() 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ée n avec vrais doublons (warning aux bons comptes).
  • Tests DuckDB : (a) table avec colonne n non-clé ; (b) clé nommée n avec 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.