Question

Force creation of table with no records (null?)

  • 17 June 2024
  • 1 reply
  • 22 views

Userlevel 2
Badge +7

Hello Forum,

 

I have a workspace which reads in a tab file with a start_date attribute and end_date attribute. These are populated with datestamp values (e.g.: 202410281200).

 

  • That reader flows to a TestFilter which determines if today is before the start date. If so, these records go to a new output writer for sites not yet started.

 

  • If today is beyond the start date. These then go on to a second testFilter, which determines if the end date has been reached or not.

 

  • If the end_date has been reached, then this goes to an output writer for historic sites

 

  • If the end_date has not yet been reached, then this goes to a output writer for live sites.

 

These test Filters are doing exactly what I want them to do. However it can be the case that sometimes there are no sites where the start_date has not yet been reached. In these cases I need the output to be an empty table. However, I’m finding that the flow is failing to overwrite any previously created tables where, for instance, at a time when it did contain map objects. In other words, I need the workspace to create an empty table even if no records are sent to the port.

 

For example, on day one the data may state that three sites have not yet started  (based on the datestamp). So, if that workspace is run it will create an output tab with three map objects. But then on day five all the start dates may have been reached - therefore no sites would be classified as ‘not yet started’. In that case I would want it to create a tab file containing no records. 

Thanks,

Stuart


1 reply

The NoFeaturesTester from the hub can be used to check for no features. The NOINPUT outputport emits a feature which can be used to create the table you want. You will then need to remove this dummy feature used to create the table, this can be done using another FeatureWriter or a SQLExecutor.

Reply