Open jaemolihm opened 3 years ago
This is an interesting request.
Currently Table
is simply an AbstractArray
. We can try to convert
things to the correct NamedTuple
but going beyond this would change the philosophy a little (part of the "philosophy" here is to see if Base
types like arrays and named tuples are sufficient for doing relational algebra problems in a convenient and performant manner). Though I can totally undertand that something more flexible and user friendly could be useful...
Ideally we'd try to make operations like push!
atomic so that if they fail then the vector is restored to the original state. I think we need to have more comprehensive checks that what was given was valid before the arrays are grown - not corrupting the table and printing a useful error message would be a lot better than the current behavior.
Just ran into this with the latest version. It seems to me that the enhancement label is a bit misleading, since the behavior described in the title is a bug. Allowing pushes of non-Named Tuples is an enhancement that might cure the problem (or not, since dimensional mismatch would still be possible), but "simply" assuring that an error doesn't stuff junk into the table would fix the bug.
julia> versioninfo()
Julia Version 1.9.2
Commit e4ee485e90 (2023-07-05 09:39 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 20 × Intel(R) Xeon(R) CPU E5-2690 v4 @ 2.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, broadwell)
Threads: 16 on 20 virtual cores
Environment:
JULIA_EDITOR = code
JULIA_NUM_THREADS =
(MSEP) pkg> status TypedTables
Project MSEP v0.2.1-pre
Status `C:\Users\rdboylan\Documents\BP\MSEP\Project.toml`
[9d95f2ec] TypedTables v1.4.3
Yes, I suppose there are two fixes here.
One it to try make the updates "atomic" on typed tables, to fix the bug of the table being corrupted. I worry that in general this is basically impossible to fix, but we should make a best effort where practical.
The second is to actually support conversion from tuples.
As shown below, a failed
push!
(due to using Tuple or Array, not NamedTuple) adds a row with dummy data.Also, would it be possible to support
push!
by Tuple or Array (based on the argument order), like in DataFrames.jl?Output:
Here's the versioninfo.