Skip to content

Commit

Permalink
fixing the NoSuchElementException when availability of the underlying…
Browse files Browse the repository at this point in the history
… table is empty (#702)
  • Loading branch information
deepakb91 authored and QubitPi committed May 17, 2018
1 parent e7fc8e0 commit 425a3b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pull request if there was one.

### Fixed:

- [Fix generate intervals logic when availability is empty](https://github.com/yahoo/fili/pull/702)
* Logic to generate intervals when `CURRENT_MACRO_USES_LATEST` flag is turned on has a bug. The code throws `NoSuchElementException` when the table has no availabilities. This PR fixes the bug by checking if the availability of the underlying table is empty.
- [Correct Druid coordinator URL in Wikipedia example](https://github.com/yahoo/fili/pull/683)
* Config value for Druid coordinator URL is mis-typed.

Expand Down Expand Up @@ -156,8 +158,10 @@ Thanks to everyone who contributed to this release!

### Added:

- [Logical Table Availability](https://github.com/yahoo/fili/pull/697)
* Added `logicalTableAvailability` to `TableUtils` which returns the union of availabilities for the logical table.
- [Latest Time Macro](https://github.com/yahoo/fili/pull/697)
* Added `logicalTableAvailability` to `TableUtils` which returns the union of intervals for the logical table.
* Added `now` parameter to `generateIntervals` for which time macros will be relatively calculated.
* Added `CURRENT_MACRO_USES_LATEST` flag which when turned on uses the first unavailable availability to generate the intervals.

- [Annotate Functional Interface](https://github.com/yahoo/fili/pull/606)
* Add `@FunctionalInterface` annotation to all functional interfaces.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.yahoo.bard.webservice.table.LogicalTable;
import com.yahoo.bard.webservice.table.LogicalTableDictionary;
import com.yahoo.bard.webservice.table.TableIdentifier;
import com.yahoo.bard.webservice.util.SimplifiedIntervalList;
import com.yahoo.bard.webservice.util.StreamUtils;
import com.yahoo.bard.webservice.util.TableUtils;
import com.yahoo.bard.webservice.web.ApiFilter;
Expand Down Expand Up @@ -297,9 +298,14 @@ public DataApiRequestImpl(
DateTimeFormatter dateTimeFormatter = generateDateTimeFormatter(timeZone);

if (BardFeatureFlag.CURRENT_MACRO_USES_LATEST.isOn()) {
DateTime firstUnavailableInstant = TableUtils.logicalTableAvailability(getTable()).getLast().getEnd();
DateTime adjustedNow = firstUnavailableInstant.isBeforeNow() ? firstUnavailableInstant : new DateTime();

SimplifiedIntervalList availability = TableUtils.logicalTableAvailability(getTable());
DateTime adjustedNow = new DateTime();
if (! availability.isEmpty()) {
DateTime firstUnavailable = availability.getLast().getEnd();
if (firstUnavailable.isBeforeNow()) {
adjustedNow = firstUnavailable;
}
}
this.intervals = generateIntervals(adjustedNow, intervals, this.granularity, dateTimeFormatter);
} else {
this.intervals = generateIntervals(intervals, this.granularity, dateTimeFormatter);
Expand Down

0 comments on commit 425a3b5

Please sign in to comment.