Skip to content

Setting is_exact = FALSE causes the col_schema_match() function to ignore logical columns #670

@tomsing1

Description

@tomsing1

Prework

Description

Setting the argument is_exact = TRUE in the col_schema_match() function seems to allow a logical column to pass validation regardless of what column type is specified.

Reproducible example

library(pointblank)

# passes, as expected
data.frame(a = 1:2, b = rep(NA, 2)) |>
  col_schema_match(col_schema(a = "integer", b = "logical"), is_exact = TRUE)

# fails, as expected
data.frame(a = 1:2, b = rep(NA, 2)) |>
  col_schema_match(col_schema(a = "integer", b = "anything"), is_exact = TRUE)

# passes, even though the logical column b is now specified as `anything`
data.frame(a = 1:2, b = rep(NA, 2)) |>
  col_schema_match(col_schema(a = "integer", b = "anything"), is_exact = FALSE)

# this also happens when the logical column contains non missing values
data.frame(a = 1:2, b = rep(TRUE, 2)) |>
  col_schema_match(col_schema(a = "integer", b = "anything"), is_exact = FALSE)

# Fails, because a type mismatch for a numeric column is still detected
data.frame(a = 1:2, b = rep(NA, 2)) |>
  col_schema_match(col_schema(a = "anything", b = "logical"), is_exact = FALSE)

Expected result

I would have expected that setting is_exact=FALSE would still catch the fact that a logical column is not of type anything.

Session info

R version 4.5.2 (2025-10-31)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.7.3

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Los_Angeles
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] pointblank_0.12.3

loaded via a namespace (and not attached):
 [1] digest_0.6.39     R6_2.6.1          fastmap_1.2.0     tidyselect_1.2.1  magrittr_2.0.3    glue_1.8.0       
 [7] tibble_3.3.0      pkgconfig_2.0.3   htmltools_0.5.9   dplyr_1.2.0       generics_0.1.4    lifecycle_1.0.5  
[13] cli_3.6.5         vctrs_0.7.1       withr_3.0.2       renv_1.1.5        compiler_4.5.2    rstudioapi_0.18.0
[19] tools_4.5.2       pillar_1.11.0     rlang_1.1.7       blastula_0.3.6   

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions