|
|
|
|
|
by notafraudster
2602 days ago
|
|
I use right_join never in SQL, but often in offline data analysis (e.g. in R). Modern R has an operator called the "pipe" (%>%) which allows left to right evaluation of functions, and so it's fairly common to write code that basically reads like, say, chained method invocations in JavaScript (i.e. object.method1().method2().method3()). The operator works so that the invoking object is automatically passed as the first argument of the function, so func(x, y) is the same as x %>% func(y). You might see where this is going. Think of left join as a join from x to y, and a right join as a join from y to x, where x is the data we keep all of and y is the data we keep only when there's a match. Then, in R, I often use right joins when my "y" data requires preprocessing, resulting in lines of code that are like: (y %>% preprocess1() %>% preprocess2() %>% right_join(x)). I could of course write this as "y_preprocessed = y %>% preprocess1() %>% ...; x %>% left_join(y_preprocessed)" but I think the former is actually a little syntactically clearer. |
|