@@ -563,6 +563,36 @@ def test_read_w_index(self):
563563 [(row [0 ], row [2 ]) for row in self ._row_data (ROW_COUNT )]))
564564 self ._check_row_data (rows , expected )
565565
566+ def test_read_w_limit (self ):
567+ ROW_COUNT = 4000
568+ LIMIT = 100
569+ session , committed = self ._set_up_table (ROW_COUNT )
570+
571+ snapshot = session .snapshot (read_timestamp = committed )
572+ rows = list (snapshot .read (
573+ self .TABLE , self .COLUMNS , self .ALL , limit = LIMIT ))
574+
575+ all_data_rows = list (self ._row_data (ROW_COUNT ))
576+ expected = all_data_rows [:LIMIT ]
577+ self ._check_row_data (rows , expected )
578+
579+ def test_read_w_range (self ):
580+ from google .cloud .spanner .keyset import KeyRange
581+ ROW_COUNT = 4000
582+ START_CLOSED = 1000
583+ END_OPEN = 2000
584+ session , committed = self ._set_up_table (ROW_COUNT )
585+ key_range = KeyRange (start_closed = [START_CLOSED ], end_open = [END_OPEN ])
586+ keyset = KeySet (ranges = (key_range ,))
587+
588+ snapshot = session .snapshot (read_timestamp = committed )
589+ rows = list (snapshot .read (
590+ self .TABLE , self .COLUMNS , keyset ))
591+
592+ all_data_rows = list (self ._row_data (ROW_COUNT ))
593+ expected = all_data_rows [START_CLOSED :END_OPEN ]
594+ self ._check_row_data (rows , expected )
595+
566596 def test_execute_sql_w_manual_consume (self ):
567597 ROW_COUNT = 4000
568598 session , committed = self ._set_up_table (ROW_COUNT )
0 commit comments