Issue with modifying an empty nested table

Open
#7,806 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
r
Domain
data

Research direction

Start by running the reproducible R example from the issue and inspect how nested table assignment handles the empty s2 case. Trace the relevant data.table code and add or run a regression test for adding an empty column to an empty nested table; done means the parent column keeps its correct type and no malformed data.table error occurs.

Written by the indexing model from the issue text.

Description

Hi all,

Yet another corner case that hit me:

tab <- data.table(s1 = list(data.table()), s2 = list(data.table()), s3 = list(data.table(v = 1)))
tab[, s1 := lapply(s1, \(x) x)]
tab[, s2 := lapply(s2, \(x) { x[, dummy := numeric()]; x})]
tab[, s3 := lapply(s3, \(x) { x[, dummy := 2]; x})]
print(tab)

                  s1             s2                s3
              <list>   <data.table>            <list>
1: <data.table[0x0]> <multi-column> <data.table[1x2]>

So, adding an empty column to an empty nested table (case s2), somehow changes the type of the parent column where the nested table is in. As a result, I get errors such as Column X ['XXX'] is a data.frame or data.table; malformed data.table.

Thanks,
Rick

Dominant language
R
Stars
3.9k
Forks
1.1k
Avg merge
14h 4m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

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.

More from Rdatatable/data.table

All issues in Rdatatable/data.table

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.