-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow :union as cols kwarg in push! and append! #2152
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Only issue is that the widening seems aggressive, but you know the tradeoffs here better than I do. I'd be happy to just have it widen in the case that missings are introduced.
Edit: also needs tests but you probably knew that already ;)
Such considerations were exactly the reason why last time we have decided not to add this functionality, because there were too many options. My thinking was that if we want something simple then it should be flexible, i.e. if the user passes
and expect it will not fail. Of course we can be more defensive - as you propose. The question is in what cases you would benefit from A midway solution would be to allow promotion only if So in short - I am open to change what I have proposed, and all options have pros and cons unfortunately.
What do you mean by this (I thought I have provided an adequate test coverage). The tests I have written pass, the ❌ is only due to unrelated CI failures. |
I don't see any changes to test files here, just the source... |
I would have expected something like
Where |
@kleinschmidt - thank you (I have forgotten to stage the test file - pushed now 😄) |
@pdeffebach - intuitively I would prefer to keep a single kwarg not to complicate the design and pick the behavior of Given this consideration I preferred to make In general I think you shoulud use |
Sounds good! |
So this was my thinking. But just to make sure we are on the right track. Let us try to think of a case when this kind of promotion in |
I agree that no one who is too "lazy" to make sure all their named-tuples have the same number of fields is going to care that much about unexpected autopromotion. The only scenario I can think of is someone who wants auto-promotion of types but doesn't realize their named tuples have different elements. Then they unexpectedly create new columns. But this seems very unlikely.
The only other concern would be discoverability. This is solved by good documentation and perhaps a few discourse answers. |
I think the scenario I had in mind was more that someone would use |
But I agree that's unlikely given that CSV.jl/JSON3.jl handle the promotion for you.... |
Yeah, I was afraid of it too. I even considered adding
Because of this in the initial message in this PR I have made the comment
as proper documentation is important here. The key concern was that So in summary we have the situation:
I understand that we converge to accepting what is currently implemented in the PR - right? Thank you for discussing this. |
Sorry for not commenting earlier. I think I'd rather have a separate If we want a flexible mode, we could have another argument for convenience which will set |
What you propose is essentially the initial design that was planned. It is more complex, but we can go for it. I would simply set I think it is natural that for If we go for it in a separate PR I can update @nalimilan - please confirm that you are OK with this plan and then I can go forward with implementing the functionality. |
@nalimilan - I have implemented what you proposed. In the end it seems it is not that problematic as I feared. The only issue is that if we have column aliases then with |
I have added the same arguments to |
@nalimilan - all tests added. |
Co-Authored-By: Milan Bouchet-Valat <nalimilan@club.fr>
Co-Authored-By: Milan Bouchet-Valat <nalimilan@club.fr>
Co-Authored-By: Milan Bouchet-Valat <nalimilan@club.fr>
Co-Authored-By: Milan Bouchet-Valat <nalimilan@club.fr>
Thank you for a huge effort to review this. I hope I have fixed everything. |
CI passes here. |
Thank you! |
Fixes #2150
@kleinschmidt and @nalimilan - I have implemented what I think is a useful minimal functionality. As usual things were more complex than I have initially expected.
(also comments helping to refine a docstring are welcome, as I usually do not get it right)