If no results in Node 2, output results from Node 1
I'm working on a graph and need your help. See the attached file for visual.
Node 1 runs and generates 59,533 records, than 3 more nodes are running (filter, modify fields, transform node-Node 2). Compare Node 1 and Node 2, if Node 2 generates 0 results, output data from Node 1.
Attached files
-
This scenario is similar to the situation that was discussed in this post. It's not the same but the logic can be adapted to select dataset A if it contains records or dataset B if there were zero records in dataset A.
A dummy record is concatenated with the data from dataset A (your Node 2) so that there is always at least one record in the dataset, with the dummy record always being the first (or only) record in the dataset.
A record count field and a dataset ID field are added to dataset A. The record count is zero indexed (meaning the dummy record will have a record count of 0). The dummy data field is removed from dataset A.
The data in the alternative dataset (your Node 1) is modified to also have the record count field and the dataset ID. In this case the record count is fixed at -1 and the dataset ID is set to "B". Note that the metadata for the two data sets is now identical.
The two data sets are then concatenated, with the records from dataset A being the first records output from the Cat node.
A transform node is then used to determine which data set to output. The first record is discarded as this will always be the dummy record. Then for subsequent records, the node examines the value of the record count field. If the record count is greater than zero then there was at least one 'real' record in dataset A so the node is configured to output the records from that dataset.If there were no 'real' records in dataset A then the node remains configured to output records from dataset B.
Note: Data360 Analyze 3.6.0 or above is needed to import the example data flow.
Attached files
-
I have come up with another way! seems to work fine. By adding a boolean field to each dataset (Node1,Node2) and setting one to false, the other to true, You can output Node 1 or 2 depending on if it has data
Basically the bottom nodes, output just the bool field, then reduce it to 1 or 2 rows (1 row if only the bottom data has data), 2 rows if both have data... then sort and grab the top row.. if false, then the top data has data, true if only the bottom data has it...
I know, its odd but it works...
a cat node with ifs would be cool.. hint hint..
I put it into a Composite so you can just copy it and drop it in...
Attached files
-
Hi Brad,
apologies, here is a version that should import into any 3.4.x instance.
Unfortunately, due to the changes in the underlying model for the data flow between the 3.6.x release series and the 3.4.x release series it's not possible to export from a later LTS release series to an earlier LTS release series - you can only export and import within the same LTS release series.
Regards,
Adrian
Attached files
-
Just to clarify the example, the logic in the blue box in the screenshot below just replicates whatever logic is being used to create the two data sets (of which one may have zero records). I used the Filter node in the red box to either allow records to be produced or to create zero records, so the logic on the right of the data flow could be tested.
Please sign in to leave a comment.
Comments
6 comments