Skip to content

Conversation

@ben-schwen
Copy link
Member

Closes #1831
Closes #4100
Supersedes #5269

Doesn't this open the same can of worms that we're seeing with setDT()? #6706, #6723, ...

We need to consider set(env$nm, ...) and a whole litany of other ways set() can be used on set(<call>, ...) besides as set(<name>, ...), right?

Originally posted by @MichaelChirico in #5269 (comment)

Basically yes, but we have to carry this ball anyway because of #7500

@github-actions
Copy link

github-actions bot commented Dec 28, 2025

No obvious timing issues in HEAD=set_automate_overalloc
Comparison Plot

Generated via commit 76675c3

Download link for the artifact containing the test results: ↓ atime-results.zip

Task Duration
R setup and installing dependencies 3 minutes and 0 seconds
Installing different package versions 22 seconds
Running and plotting the test cases 4 minutes and 4 seconds

@codecov
Copy link

codecov bot commented Dec 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.97%. Comparing base (dc69b3d) to head (76675c3).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7538   +/-   ##
=======================================
  Coverage   98.97%   98.97%           
=======================================
  Files          87       87           
  Lines       16733    16733           
=======================================
  Hits        16561    16561           
  Misses        172      172           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

test(2356.2, options=c(datatable.alloccol=1L), set(DT, j="c", value=3), data.table(a=1, b=2, c=3))
# ensure := and set are consistent if they need to overallocate
DT = data.table(); DT2 = data.table()
test(2356.3, options=c(datatable.alloccol=1L), {for (i in seq(10L)) set(DT, j = paste0("V",i), value = i)}, {for (i in seq(10)) DT2[, sprintf("V%d",i) := i]})
Copy link
Member

Choose a reason for hiding this comment

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

I think we need ; DT and ; DT2 here, a for loop returns NULL so now the test just checks the code runs:

x = for (i in 1:10) i
dput(x)
# NULL

{
# If removing columns from a table that's not selfrefok, need to call setalloccol first, #7488
if ((is.null(value) || (is.list(value) && any(vapply_1b(value, is.null)))) && selfrefok(x, verbose=FALSE) < 1L) {
if (((is.null(value) || (is.list(value) && any(vapply_1b(value, is.null)))) && selfrefok(x, verbose=FALSE) < 1L) ||
Copy link
Member

Choose a reason for hiding this comment

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

too many parentheses :)

I propose this helper:

.set_needs_alloccol = function(x, value) {
  if (truelength(x) <= length(x)) return(TRUE)
  if (selfrefok(x, verbose=FALSE) >= 1L) return(FALSE)
  if (is.null(value)) return(TRUE)
  if (!is.list(value)) return(FALSE)
  any(vapply_1b(value, is.null))
}

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.

Internal error: DT passed to assign has not been allocated enough column slots data.table allocates over alloc.col limit with [,:= but not set()

2 participants