i am having a case where data is provided redundantly in 2 columns, or normally in single column. The 2 cases happen let’s say randomly, so i am willing to implement a solution which tries merging the 2 columns, and if this is not possible, then continue with single column.
I figured this trivial solution:
However, the catch does not take its lower branch, even though there is error in upper branch (obviously merging cannot happen if one column is missing).
Did i discover a bug with Catch node, or this is expected?
Can you help sharing if there is any best practice to solve similar case?
Meanwhile i will workaround the case as talked here: Checking for existance of a column?
Thanks anyways for your inputs about the above case.
What do you know about the data? Does the table contain only 1 or 2 columns or can it have more? In the former case you can simply use
This will output a flow variable
Number Columns. The you can use a case switch controlled by this variable to either pass data forward if there is a single column or do some operation (e.g. merging) if there are two.
Good point, thank you for the suggestion. Generally this should be one of the possible solutions, but since other parts of the table could be dynamic (due to other error on data provider side), i am working around by explicitly looking for the concerned column’s name.
Many thanks for the suggestion anyways - in case i trusted data source to have constant set of columns, i would go with your solution
Java Snippet and
If Switch as a possible solution:
Regarding a dynamic solution. I agree with your arguments. But in this particular scenario
Try+Catch is not a good option. And it is not a bug with
Try+Catch. I attach an example workflow, where
Catch works as you would expect: breakpoint.knwf (14.4 KB).
The trick is that in your case
Column Merger did not fail. It returned a warning (the triangle on the traffic light) and did not execute. That’s why
Catch did not properly output the content of the second input port
Thank you, Andrew! This is simple and elegant, so i will continue with this.
Thank you, Misha!
It’s arguable if a formerly configured and running node is failing or not if its settings are not available anymore - i thought this is a fail, that is why i believed it’s a trivial solution to use try-catch. Now i see why it did not run.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.