Skip to content

Issue with modifying an empty nested table #7806

Description

@rickhelmus

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions