ExposureRange is a time interval (or a set of Exposures) and we cannot use equi-join for corresponding dataset, instead for input datasets we should do something like:
-- "UnitUniverse" must include Exposure table.
|
UnitUniverse JOIN
|
(SELECT Dataset.valid_first, Dataset.valid_last, ...
|
FROM Dataset JOIN DatasetCollection .......) DS_42
|
ON (DS_42.valid_first <= Exposure.datetime_begin AND DS_42.valid_last >= Exposure.datetime_end)
|
The idea is simple - find a ExposureRange which fully covers an Exposure. I think that it is expected that there is always one such dataset, it's not clear what to do if there is none or if there is more that one (if there is none then we skip that part of the unit universe entirely, but if there is more than one there will be many ExposureRanges returned). And I think that this join will be super-inefficient compared to simple equi-join.
It is not at all clear what to do for the output dataset types with ExposureRange units. The whole idea of the pre-flight is to generate all possible outputs but in case of ExposureRange possible outputs set is probably a combination of Exposure begin/end times (or even beyond that) so it's not useful. We'll need some other idea how to handle outputs later.
Because ExposureRange does not exists there are no corresponding columns added to SELECT list, we need to add that too. Unlike all other DataUnits which can only enter resulting row once (e.g. only one Exposure can appear on one path even if there are many tasks working on it) there may be several ExposureRanges which are different, e.g. One calibration has exposure range covering time from minus to plus infinity, but other calibration can be done on per-night basis. So all different DatasetTypes with ExposureRange need their own set of valid_first/valid_last columns in the result.
Although ExposureRange is a DataUnit it is a very special unit and need special handling in pre-flight. ExposureRange ius basically a time interval:
ExposureRange:
dependencies:
required:
- Instrument
link:
- valid_first
- valid_last
doc: >
An inclusive range of Exposure dates that may be open in either
direction, typically used to identify master calibration products.
There is no SQL table associated with ExposureRanges; there is no
additional information associated with an ExposureRange besides the
instrument, valid_first, and valid_last fields already present in
Dataset.
As comment says there is no regular DataUnit table like for other units, the only place that knows about range is a Dataset table.
Here is how pre-flight works today at the very-high level with regular DataUnits which all have corresponding tables: