@Override
  public KsMaterializedQueryResult<WindowedRow> get(
      final GenericKey key,
      final int partition,
      final Range<Instant> windowStartBounds,
      final Range<Instant> windowEndBounds,
      final Optional<Position> position
  ) {
    try {
      final ReadOnlyWindowStore<GenericKey, ValueAndTimestamp<GenericRow>> store = stateStore
          .store(QueryableStoreTypes.timestampedWindowStore(), partition);

      final Instant lower = calculateLowerBound(windowStartBounds, windowEndBounds);

      final Instant upper = calculateUpperBound(windowStartBounds, windowEndBounds);

      try (WindowStoreIterator<ValueAndTimestamp<GenericRow>> it
          = cacheBypassFetcher.fetch(store, key, lower, upper)) {

        final Builder<WindowedRow> builder = ImmutableList.builder();

        while (it.hasNext()) {
          final KeyValue<Long, ValueAndTimestamp<GenericRow>> next = it.next();

          final Instant windowStart = Instant.ofEpochMilli(next.key);
          if (!windowStartBounds.contains(windowStart)) {
            continue;
          }

          final Instant windowEnd = windowStart.plus(windowSize);
          if (!windowEndBounds.contains(windowEnd)) {
            continue;
          }

          final TimeWindow window =
              new TimeWindow(windowStart.toEpochMilli(), windowEnd.toEpochMilli());

          final WindowedRow row = WindowedRow.of(
              stateStore.schema(),
              new Windowed<>(key, window),
              next.value.value(),
              next.value.timestamp()
          );

          builder.add(row);
        }

        return KsMaterializedQueryResult.rowIterator(builder.build().iterator());
      }
    } catch (final Exception e) {
      throw new MaterializationException("Failed to get value from materialized table", e);
    }
  }
@Test
  public void shouldFetchWithStartUpperBoundIfLowest() {
    // Given:
    final Range<Instant> startBounds = Range.closed(
        NOW,
        NOW.plusSeconds(10)
    );

    final Range<Instant> endBounds = Range.closed(
        NOW.plusSeconds(5).plus(WINDOW_SIZE),
        NOW.plusSeconds(15).plus(WINDOW_SIZE)
    );

    // When:
    table.get(A_KEY, PARTITION, startBounds, endBounds);

    // Then:
    verify(cacheBypassFetcher).fetch(eq(tableStore), any(), any(), eq(startBounds.upperEndpoint()));
  }