I have 2 ways of data preparation - how can I merge them together if one way could not be executed

Hi there,

i have a Problem with my flow - the Data is not always the same but we want to use the same flow. Therefore I added two ways how the date will be prepared.

But one way will always be empty and I would need to connect the outputs to the next node wit only one input. As it could be the case that the first way could not be executed i cant use the concatanate node…

Here is a picture to see the problem I think my explainations are not that easy to follow :wink:

Thanks and br Daniel

Hi,
Have you try to use If switch/End if (or empty table switch if the criteria is empty table) ?
Best,

1 Like

Welcome back… so the top one might be failing and then you want the bottom one to run instead?

Do both nodes in the end produce the same result?

If so you can use a try-catch block:

The table (or workflow branch) that finishes at the bottom of the Catch Errors node only runs, if the upper branch fails.

2 Likes

Yes I tried but it was not the solution… At the end there is “no data availavle”

@drabbit maybe you could try and take a look at these examples

2 Likes

If the table is not erroring out then empty table switch may do as mentioned here.

Set up could look like this:

Note: The column expressions node in the bottom branch is not doing anything other than triggering the bottom branch via flow variable…

3 Likes

Hello,
To choose between If switch or Try/Catch, it would be usefull to know :
“as it could be the case that the first way could not be executed” but why ? Is there anyway to know that before executing operations (so that If switch may be decide a priori) or it could be only noticed during the operations (and Try/Catch is the way).
Best,

1 Like

I think the issue in my case is that I have here this Unpivoting node which is using a wildcard. In the case the Column is not there I receive a warning "No column value defined for unpivoting operation. Which ends in “No data available!”

Therefore I think I can’t use the empty table switch.

also the try node seems not to work in this case - i tried to have a look at the examples but I was not able to run it due to missing extentions which I was not able to install.

I also tried it with a minimum of nodes but something is not working or do i use the nodes wrong?

2 Likes

Your set up looks correct to be honest.

Do you mind sharing this minimal example so I can take a look?

I think as @JPollet said earlier - it is important to understand what scenario is happening in your workflow - i.e. is an empty table produced or is one part of the WF failing?

Depending on that the solution will look differently.

One option could be : column filter as it is then Extract Table Spec node (this node list in particular the column names) and test if there exist the column(s) use for pivoting. Then define (with variable) the node If switch with the result of the test.
Joel

1 Like

Hi guys,

thanks a lot for your support - this is what I really like in this community.

here is an example flow. The main problem is that for Dataset 1 we do not know what values will be delivered within the Topic section. Dataset 2 has not the Topic section at all and this is the reason why I would need the if node or the try node.

But I dont know who to set this up
KNIME_exampleflow.knwf (43.2 KB)

Thanks for the example. Some initial feedback as to why neither the try/catch nor the empty table nodes were helping:

  1. Try Catch:
    The Unpivot node unfortunately does not fail (so show an error) when no column that matches the pattern is in the data set - it produces “only” a warning and thus the second branch is never triggered

  1. Empty table: The unpivot node is also not producing an empty table (= successful execution, but no data in the table other than headers).

Do not yet have a solution, but will look into this tonight - therefore sharing my train of thought for now:

  1. Find a way to make “something” fail - this would require checking if “Topic |*” pattern is in the data set - if that works with a node that produces an error you can then use the try / catch
  2. Check if a column is in a data set and use this to create a variable for an IF Switch of CASE Switch Node
  3. ensure there is always at least one column that matches the pattern - add it using a constant value column and the value in each cell is the same and should be something you’d never see as data in your other columns (e.g. “/-$35465–##”) - once you are done with your unpivoting you filter out those rows using a row filter searching for “/-$35465–##”
2 Likes

I try too with Try/Catch but with no success : I’m interesting for a possible solution !
Here is a suggestion with a test on the presence or not of
Topic columns and two branches for processing (option 2 as @MartinDDDD and I explain earlier). It works : at least it produces something but is it what you are waiting for ?

KNIME_exampleflow_suggest.knwf (49,7 Ko)

Joel

1 Like

@JPollet have you considered along the lines of the suggestions from @MartinDDDD to extract the table specs and then filter if a Column of that name is present?

Then you determine which port to use and put that into a CASE SWITCH construct

Then you collect the correct branch in the end:

2 Likes

@mlauber71 Yes with a slightly more straight test :

Joel

2 Likes

@mlauber71 by the way, activate branches with variable flow is very elegant and could be useful !
Joel

1 Like

@JPollet one advantage of CASE construct could be that you can have more than 2 cases.

1 Like

Yes of course.
Just one thing : for If Switch the ports are label “top” and “bottom” which is uncommon in Knime and puzzle me each time ! It gives the possibility of “both” but I don’t know when this could be applicable.
Joel

1 Like

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