@@ -1003,6 +1003,60 @@ def test_read_w_ranges(self):
10031003 expected = all_data_rows [START + 1 : END + 1 ]
10041004 self ._check_row_data (rows , expected )
10051005
1006+ def test_read_partial_range_until_end (self ):
1007+ row_count = 3000
1008+ start = 1000
1009+ session , committed = self ._set_up_table (row_count )
1010+ snapshot = session .snapshot (read_timestamp = committed , multi_use = True )
1011+ all_data_rows = list (self ._row_data (row_count ))
1012+
1013+ expected_map = {
1014+ ('start_closed' , 'end_closed' ): all_data_rows [start :],
1015+ ('start_closed' , 'end_open' ): [],
1016+ ('start_open' , 'end_closed' ): all_data_rows [start + 1 :],
1017+ ('start_open' , 'end_open' ): [],
1018+ }
1019+ for start_arg in ('start_closed' , 'start_open' ):
1020+ for end_arg in ('end_closed' , 'end_open' ):
1021+ range_kwargs = {start_arg : [start ], end_arg : []}
1022+ keyset = KeySet (
1023+ ranges = (
1024+ KeyRange (** range_kwargs ),
1025+ ),
1026+ )
1027+
1028+ rows = list (snapshot .read (
1029+ self .TABLE , self .COLUMNS , keyset ))
1030+ expected = expected_map [(start_arg , end_arg )]
1031+ self ._check_row_data (rows , expected )
1032+
1033+ def test_read_partial_range_from_beginning (self ):
1034+ row_count = 3000
1035+ end = 2000
1036+ session , committed = self ._set_up_table (row_count )
1037+ snapshot = session .snapshot (read_timestamp = committed , multi_use = True )
1038+ all_data_rows = list (self ._row_data (row_count ))
1039+
1040+ expected_map = {
1041+ ('start_closed' , 'end_closed' ): all_data_rows [:end + 1 ],
1042+ ('start_closed' , 'end_open' ): all_data_rows [:end ],
1043+ ('start_open' , 'end_closed' ): [],
1044+ ('start_open' , 'end_open' ): [],
1045+ }
1046+ for start_arg in ('start_closed' , 'start_open' ):
1047+ for end_arg in ('end_closed' , 'end_open' ):
1048+ range_kwargs = {start_arg : [], end_arg : [end ]}
1049+ keyset = KeySet (
1050+ ranges = (
1051+ KeyRange (** range_kwargs ),
1052+ ),
1053+ )
1054+
1055+ rows = list (snapshot .read (
1056+ self .TABLE , self .COLUMNS , keyset ))
1057+ expected = expected_map [(start_arg , end_arg )]
1058+ self ._check_row_data (rows , expected )
1059+
10061060 def test_read_with_range_keys_index_single_key (self ):
10071061 row_count = 10
10081062 columns = self .COLUMNS [1 ], self .COLUMNS [2 ]
0 commit comments