microsoft / Trill

Trill is a single-node query processor for temporal or streaming data.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do i do a full join?

nsulikowski opened this issue · comments

There is Join(...) and LeftOuterJoin(...)
How about FullJoin ?

Within Trill, LeftOuterJoin is implemented as a helper method over three operations:

  • EquiJoin
  • LeftAntiSemiJoin (WhereNotExists)
  • Union

It looks just like this:

`
public static IStreamable<TKey, TResult> LeftOuterJoin<TKey, TLeft, TRight, TJoinKey, TResult>(
this IStreamable<TKey, TLeft> left,
IStreamable<TKey, TRight> right,
Expression<Func<TLeft, TJoinKey>> leftKeySelector,
Expression<Func<TRight, TJoinKey>> rightKeySelector,
Expression<Func<TLeft, TResult>> outerResultSelector,
Expression<Func<TLeft, TRight, TResult>> innerResultSelector)
{
Invariant.IsNotNull(left, nameof(left));
Invariant.IsNotNull(right, nameof(right));

        return left.Multicast(right, (l_mc, r_mc) =>
        {
            var lasj = l_mc.WhereNotExists(r_mc, leftKeySelector, rightKeySelector).Select(outerResultSelector);
            var innerJoin = l_mc.Join(r_mc, leftKeySelector, rightKeySelector, innerResultSelector);
            return lasj.Union(innerJoin);
        });
    }

`

So adding a FullOuterJoin method can be done from extending the code above with a second WhereNotExists and a second Union operation, plus another selector expression in the method signature.

Any interest in writing a PR to contribute this to the public API? :-) We'd help you through it if you are so inclined.

Eep, sorry, for some reason I didn't get your edited comment, only the original one.

I'm relatively new to GitHub myself, but I think the way to do it is to create your own branch (in this repo if you can) and create a pull request from the web interface. I've not created a PR from visual studio directly.

@nsulikowski, @cybertyche for external contributors the pattern is usually to fork the repo then submit a pull request from the fork.

If you've made the change already to an (unforked) clone of the repo locally, you can fork the repo from GitHub then update your local clone's origin to point at your fork (same as shown here, though it's for Azure DevOps]. You should then be able to push your changes (to your fork) and open a pull request (from your fork to the original).

Nicely done, @nsulikowski ! And thank you for the assist, @NickDarvey .