Remind me, which is the prefer method to combine/j...
# nostupidquestions
e
Remind me, which is the prefer method to combine/join channels to ensure files are in sync by meta; combine or join? :P
j
I find it's better to use combine, as join will silently drop duplicates in the left channel:
Copy code
ch_a = channel.of(
    ["a", 1],
    ["a", 2],
    ["b", 3])

ch_b = channel.of(["a", 4])

ch_a.join(ch_b, by: 0).view() { it -> "join: " + it  } 
> join: [a, 1, 4]

ch_a.combine(ch_b, by: 0).view() { it -> "combine: " + it  } 
> combine: [a, 1, 4]
> combine: [a, 2, 4]
🙏 1
party this 1
Unless you need any of the extra features of join, that is - the
remainder
feature is very nice
a
FWIW
join
doesn't have to be silent fail. I think
failOnDuplicate
is your friend in those situations. So it does sort of depend on what your intention is with the join/combine operation which one you pick, although in many common cases they produce the same result when using the
by
argument of
combine
👍 1
e
@Simon Pearce ^
a
join
for 1-to-1 joining. I almost always use it with
failOnDuplicate:true
and
failOnMismatch:true
.
combine
for 1-to-many or many-to-1 merging.
Also important is
join
with
remainder:true
for handling optional outputs.
j
Would love to see join, combine + cross all deprecated + replaced with a single join operator that just defines the type of join:
Copy code
join(by: 0, type: "left")
join(by: 0, type: "inner", failOnMismatch: true)
etc...
👍 1
❗ 1
s
I think @Ben Sherman wanted to remove most of the operators
👍 1
b
yeah I'd like to introduce a v2 operator set that just has
join
for all of your joining needs at present, using
combine
with the
by
option gives you a proper SQL join