Skip to content
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

Replace left table values by right table values in left-join on match #522

Open
statquant opened this issue Jan 7, 2024 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@statquant
Copy link

Hello and happy new year.
In kdb a very useful feature of lj is that when a the right table keys are matching the left table the values of common columns are taken from the right table.
This feels quite 'natural' you essentially update.
While this is doable right now by keeping the 'match' column and overriding values (by the way it might be better to use TRUE/FALSE instead of character?) it implies some overhead.
Would you consider adding the feature?
Kind regards

@statquant statquant changed the title Replace NA values of left table in joins Replace left table values by right table values in left-join on match Jan 7, 2024
@SebKrantz
Copy link
Owner

SebKrantz commented Jan 14, 2024

Hi, can you provide an R example of this and indicate why it is useful. Currently all joins but the right join preserve the left tables id columns. Coercions to the largest common type if join columns have different types are done internally in fmatch(). I believe this is a quite natural setup....

@D3SL
Copy link

D3SL commented Feb 5, 2024

What statquant is describing is closer to an "upsert" than a true left join. The main use case is when you have multiple tables of overlapping data and want to overlay them in order to produce a single final product. It's an extremely useful operation when dealing with real world data that's come from multiple sources or was inconsistently maintained. In a way it's like a reverse fcoalesce that keeps the last rather than first value, and operates at a table level.

There are ways to approximate this in data.table, dplyr, and other libraries it's not exactly this and isn't quite clean or parsimonious.

@SebKrantz
Copy link
Owner

SebKrantz commented Feb 11, 2024

Thanks. I think this would be implemented in a different function then. For the moment this is not a priority, so I can keep it open but don't think an implementation will follow in the near future.

@SebKrantz SebKrantz added the enhancement New feature or request label Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants