Skip to content

Commit

Permalink
Spanner: Adding system test for "partial" key ranges (#4631)
Browse files Browse the repository at this point in the history
This is a follow-on to #4618.
  • Loading branch information
chemelnucfin authored and dhermes committed Dec 20, 2017
1 parent 4d6cd26 commit 157b498
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions spanner/tests/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,60 @@ def test_read_w_ranges(self):
expected = all_data_rows[START+1 : END+1]
self._check_row_data(rows, expected)

def test_read_partial_range_until_end(self):
row_count = 3000
start = 1000
session, committed = self._set_up_table(row_count)
snapshot = session.snapshot(read_timestamp=committed, multi_use=True)
all_data_rows = list(self._row_data(row_count))

expected_map = {
('start_closed', 'end_closed'): all_data_rows[start:],
('start_closed', 'end_open'): [],
('start_open', 'end_closed'): all_data_rows[start+1:],
('start_open', 'end_open'): [],
}
for start_arg in ('start_closed', 'start_open'):
for end_arg in ('end_closed', 'end_open'):
range_kwargs = {start_arg: [start], end_arg: []}
keyset = KeySet(
ranges=(
KeyRange(**range_kwargs),
),
)

rows = list(snapshot.read(
self.TABLE, self.COLUMNS, keyset))
expected = expected_map[(start_arg, end_arg)]
self._check_row_data(rows, expected)

def test_read_partial_range_from_beginning(self):
row_count = 3000
end = 2000
session, committed = self._set_up_table(row_count)
snapshot = session.snapshot(read_timestamp=committed, multi_use=True)
all_data_rows = list(self._row_data(row_count))

expected_map = {
('start_closed', 'end_closed'): all_data_rows[:end+1],
('start_closed', 'end_open'): all_data_rows[:end],
('start_open', 'end_closed'): [],
('start_open', 'end_open'): [],
}
for start_arg in ('start_closed', 'start_open'):
for end_arg in ('end_closed', 'end_open'):
range_kwargs = {start_arg: [], end_arg: [end]}
keyset = KeySet(
ranges=(
KeyRange(**range_kwargs),
),
)

rows = list(snapshot.read(
self.TABLE, self.COLUMNS, keyset))
expected = expected_map[(start_arg, end_arg)]
self._check_row_data(rows, expected)

def test_read_with_range_keys_index_single_key(self):
row_count = 10
columns = self.COLUMNS[1], self.COLUMNS[2]
Expand Down

0 comments on commit 157b498

Please sign in to comment.