Skip to content

Commit f1f1090

Browse files
cnfaitkukushkingmalachi-constant
authored
support for pagination for timestream.list_databases and timestream.list_tables (#1846)
Co-authored-by: kukushking <[email protected]> Co-authored-by: Lucas Hanson <[email protected]>
1 parent fec1f7e commit f1f1090

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

awswrangler/catalog/_get.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def get_tables(
242242
243243
Note
244244
----
245-
Please, does not filter using name_contains and name_prefix/name_suffix at the same time.
245+
Please, do not filter using name_contains and name_prefix/name_suffix at the same time.
246246
Only name_prefix and name_suffix can be combined together.
247247
248248
Parameters
@@ -279,7 +279,7 @@ def get_tables(
279279
args: Dict[str, str] = {}
280280
if (name_prefix is not None) and (name_suffix is not None) and (name_contains is not None):
281281
raise exceptions.InvalidArgumentCombination(
282-
"Please, does not filter using name_contains and "
282+
"Please, do not filter using name_contains and "
283283
"name_prefix/name_suffix at the same time. Only "
284284
"name_prefix and name_suffix can be combined together."
285285
)

awswrangler/timestream.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,14 @@ def list_databases(
536536
537537
"""
538538
client: boto3.client = _utils.client(service_name="timestream-write", session=boto3_session)
539-
dbs = client.list_databases()
540-
return [db["DatabaseName"] for db in dbs["Databases"]]
539+
540+
response: Dict[str, Any] = client.list_databases()
541+
dbs: List[str] = [db["DatabaseName"] for db in response["Databases"]]
542+
while "nextToken" in response:
543+
response = client.list_databases(nextToken=response["nextToken"])
544+
dbs += [db["DatabaseName"] for db in response["Databases"]]
545+
546+
return dbs
541547

542548

543549
def list_tables(database: Optional[str] = None, boto3_session: Optional[boto3.Session] = None) -> List[str]:
@@ -573,9 +579,11 @@ def list_tables(database: Optional[str] = None, boto3_session: Optional[boto3.Se
573579
574580
"""
575581
client: boto3.client = _utils.client(service_name="timestream-write", session=boto3_session)
576-
if database:
577-
tables = client.list_tables(DatabaseName=database)
578-
else:
579-
tables = client.list_tables()
580-
581-
return [tbl["TableName"] for tbl in tables["Tables"]]
582+
args = {} if database is None else {"DatabaseName": database}
583+
response: Dict[str, Any] = client.list_tables(**args)
584+
tables: List[str] = [tbl["TableName"] for tbl in response["Tables"]]
585+
while "nextToken" in response:
586+
response = client.list_tables(**args, nextToken=response["nextToken"])
587+
tables += [tbl["TableName"] for tbl in response["Tables"]]
588+
589+
return tables

0 commit comments

Comments
 (0)