Skip to content

fix: suppress spurious warning when col_select skips all columns - #627

Closed
LeonidasZhak wants to merge 3 commits into
tidyverse:mainfrom
LeonidasZhak:fix/col-select-all-skipped-warning
Closed

LeonidasZhak wants to merge 3 commits into
tidyverse:mainfrom
LeonidasZhak:fix/col-select-all-skipped-warning

Conversation

@LeonidasZhak

Copy link
Copy Markdown

Summary

When col_select results in all columns being skipped (e.g. via any_of() with non-existent columns), summary.col_spec() now returns early instead of calling min() on an empty vector, which produced a confusing "no non-missing arguments to min" warning.

Fixes #521

Reprex

library(vroom)
foo <- "a,b,c\n1,2,3\n"

# Before: produces warning
# Warning: no non-missing arguments to min; returning Inf
vroom(I(foo), delim = ",", col_select = any_of("d"))

# After: no warning, returns empty tibble
vroom(I(foo), delim = ",", col_select = any_of("d"))

Changes

  • R/col_types.R: Add early return in summary.col_spec() when all columns are skipped
  • tests/testthat/test-vroom.R: Add test for any_of() with non-existent columns

Tests run

  • devtools::test(filter = "vroom"): 514 passed, 0 failed
  • devtools::test(filter = "col_types"): 14 passed, 0 failed

Related

The %e format specifier (day with optional leading space) required exactly
2 characters to be consumed because consumeIntegerWithSpace called
consumeInteger with the default exact=true. This caused single-digit days
like '1' to fail parsing even though the format is designed to accept them.

Fix by passing exact=false to consumeInteger, matching the behavior of %d
which already uses exact=false.

Fixes tidyverse/readr#1559
Update README to clarify that readr's second edition (version 2.0.0 and later) uses vroom::vroom() as its parsing engine by default.

Fixes #585
When col_select results in all columns being skipped (e.g. via
any_of() with non-existent columns), summary.col_spec() now returns
early instead of calling min() on an empty vector, which produced a
confusing 'no non-missing arguments to min' warning.

Fixes #521

# any_of() with non-existent columns should return empty tibble without warning
expect_no_warning(
result <- vroom(I(foo), delim = ",", col_select = any_of("d"), show_col_types = FALSE)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
result <- vroom(I(foo), delim = ",", col_select = any_of("d"), show_col_types = FALSE)
result <- vroom(
I(foo),
delim = ",",
col_select = any_of("d"),
show_col_types = FALSE
)


# any_of() with existing columns should work normally
expect_no_warning(
result <- vroom(I(foo), delim = ",", col_select = any_of("a"), show_col_types = FALSE)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
result <- vroom(I(foo), delim = ",", col_select = any_of("a"), show_col_types = FALSE)
result <- vroom(
I(foo),
delim = ",",
col_select = any_of("a"),
show_col_types = FALSE
)

@LeonidasZhak

Copy link
Copy Markdown
Author

I am withdrawing this PR as part of a broader cleanup of an oversized automated contribution batch. I am sorry for the review noise and the pressure this may have put on maintainers. Going forward I will keep contributions to this project much more limited and higher-signal, ideally only one or two focused PRs at a time. Thank you for maintaining the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cryptic error messages when col_select has no valid columns

1 participant