-
Notifications
You must be signed in to change notification settings - Fork 168
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
Add support for self (left / right / inner / cross) join #290
Comments
Hmm, we could support cartesian powers up to a certain number of degrees (although, they'd be very quickly impractical...) What would be the point of doing this with outer joins? |
Hey lukaseder If you have a Person(Id, ParentId) and this Dataset:
you could make a LeftOuterJoin with d1.ParentId == d2.Id to get the Persons and their Parent in a tuple and the Persons that dont have a parent (maybe to handle these seperatly):
About your number of degrees question, you could start with 2, I think that would cover most use cases, If you wanted more, ýou could go the established route by giving the dataset again and again via parameter. If you'd make more degress, I think you would also need a TriPredicate, QuadPredicate, etc? Your thoughts? |
OK, I see. That might make sense indeed, at least for degree 2. I don't think it would be a reasonable extension for higher degree joins as the ordering semantics might become quite complex. |
Yes, so I suggest, that a join (l/r/i/c) without another stream as parameter would be automatically a Self-Join, like this:
There's also a case for calling them, speraratly, not overloading, selfCrossJoin, selfInnerJoin, etc., that depends on your philosophy. If you're interested, I'll shoot you a pull-request |
The keyword "self" should definitely need to be part of the naming, otherwise, the overload with the existing joins might be:
So: <T> Seq<Tuple2<T, T>> crossSelfJoin()
<T> Seq<Tuple2<T, T>> innerSelfJoin(BiPredicate<? super T, ? super T> predicate)
<T> Seq<Tuple2<T, T>> leftOuterSelfJoin(BiPredicate<? super T, ? super T> predicate)
<T> Seq<Tuple2<T, T>> rightOuterSelfJoin(BiPredicate<? super T, ? super T> predicate) Sure, a pull request would be greatly appreciated! |
Why isn't here a shortcutmethod of being able to Join a Sequence with itself, like this (from Seq.java):
(As addition to Seq.java)
Or why wouldn't that make sense? Ok, Streams are one-shot, therefore I have to convert it to a list, which isnt lazy, but it would safe me a lot of hastle writing the additional code, e.g. writing the conversion myself beforehand.
Same of course with Inner-, LeftOuter-, and RightOuterJoin.
The text was updated successfully, but these errors were encountered: