Skip to content

Commit 94b076c

Browse files
authored
fix: timestream empty batches (#2098)
* Fix timestream empty batches * Linting
1 parent 9b5db44 commit 94b076c

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

awswrangler/timestream.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,18 @@ def _write_batch(
8181
if len(record["MeasureValues"]) == 0:
8282
continue
8383
records.append(record)
84-
_utils.try_it(
85-
f=timestream_client.write_records,
86-
ex=(timestream_client.exceptions.ThrottlingException, timestream_client.exceptions.InternalServerException),
87-
max_num_tries=5,
88-
DatabaseName=database,
89-
TableName=table,
90-
Records=records,
91-
)
84+
if len(records) > 0:
85+
_utils.try_it(
86+
f=timestream_client.write_records,
87+
ex=(
88+
timestream_client.exceptions.ThrottlingException,
89+
timestream_client.exceptions.InternalServerException,
90+
),
91+
max_num_tries=5,
92+
DatabaseName=database,
93+
TableName=table,
94+
Records=records,
95+
)
9296
except timestream_client.exceptions.RejectedRecordsException as ex:
9397
return cast(List[Dict[str, str]], ex.response["RejectedRecords"])
9498
return []

0 commit comments

Comments
 (0)