# Joiner with many rows

Hello darlings!

I wanted to share a recurring problem in Knime, and how you think about solving it. Example: When I do a joiner between two tables with two columns in common, the number of rows increases significantly. A simple duplicate row filter is not ideal for this type of treatment because it eliminates many sensitive rows. I know that a groupby can often be viable, what else do you guys suggest or use in this case?

Thanks!

@Cairo first you might want to investigate why you have so many (unwanted?) duplicate rows. More often than not the question is not one of technology but of concept:

3 Likes

Hi @Cairo , I would agree with @mlauber71 's comments about duplication in general.

Additionally, there is no â€śgenericâ€ť solution to the problem, unless you can tell us what outcome you are expecting.

If I have duplication of â€ścodeâ€ť in two tables and I want to join on â€ścodeâ€ť then obviously the duplication is going to multiply up the rows, as the resultant row count is the product of the occurrences of â€ścodeâ€ť in the two tables. ie If the same â€ścodeâ€ť appears twice in one table and three times in the other, then the resultant join will be 6 rows ( 2 x 3).

If you donâ€™t want this â€śmultiplication through duplicationâ€ť, then you have to decide what you need to do to avoid it.

Now it could be that the duplicates are erroneous, in which case you need to correct the data at source, or you need to de-duplicate.

If the duplicates are not erroneous, and there is other data associated with the different rows that you wish to keep, then this suggests that you are missing a crucial additional â€śkeyâ€ť that would make each row of your data unique (the primary key). Only when joining values that are unique in at least one of the two joining tables can you expect your join not to increase the resultant row count.

So, your choices are generally the following:

1. de-duplicate or somehow filter your input data to ensure that a â€śuniqueâ€ť subset of at least one of your tables is presented to the join.
2. find additional key columns on one of your tables that when combined together will uniquely identify a row ( the â€śprimary keyâ€ť), and use all of those columns in the join. If one or more of those columns is not present in the other table, then the data in that table is deficient, and you need to take steps to either add the additional â€śkeyâ€ť columns to the other table, which may mean you have to go back to the source of the data to get it corrected, or else you have to return to option 1.

Ultimately though, as said at the beginning, you need to decide what result you want. KNIME cannot decide that for you. You cannot just say â€śI donâ€™t want to remove duplicates but I donâ€™t want to see the duplicates eitherâ€ť, which is currently the situation you appear to find yourself in.

6 Likes

@mlauber71 and @takbb already pointed out the most important things. The only thing I like to add here is besides the Group by node in certain situations a join might not even be required and sorter + column appender can give the result (Please be aware that this highly depends on your use case which I donâ€™t know)
br

Absolutelly, thanks for all answers, itâ€™s a currently problem but with some possible solutions.

Great text, Lauber! Thanks for help the community

1 Like

I would add that the columns brought in the group are also fundamental for this. Depending on, if you passed something like list and then had to pass the ungroup to pass it to the column, the groupby might have been irrelevant. But, bringing in the right columns can definitely solve this problem.

Hi guys,

I saw that this topic was solved, but if I can add a tip or 2â€¦ lol

At the join node, you can tell one or more fieldsâ€¦ yeap, distinct clauses is great and you can groupby too beforeâ€¦ BUT, you can set exactly or any cases, pass 1 or more match fields, use expressionâ€¦ well some interesting solutions that can add some insights too. I thought about a flag to to sign for both tables to control itâ€¦ well. try, try and try harder to solve some problemsâ€¦ lol againâ€¦

Thats is folks,

BR, Denis

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.