Skip to content

Commit 0e120ff

Browse files
committed
refactor(athena): simplify retry predicate to boolean expression
Signed-off-by: Daisuke Taniwaki <daisuketaniwaki@gmail.com>
1 parent 1e2ddf5 commit 0e120ff

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

dbt-athena/src/dbt/adapters/athena/connections.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,12 @@ def execute(
168168
@retry(
169169
# No need to retry if TOO_MANY_OPEN_PARTITIONS occurs.
170170
# Otherwise, Athena throws ICEBERG_FILESYSTEM_ERROR after retry,
171-
# because not all files are removed immediately after first try to create table
171+
# because not all files are removed immediately after first try to create table.
172+
# Also skip retry on query timeout since it is a deterministic failure.
172173
retry=retry_if_exception(
173174
lambda e: (
174-
False
175-
if catch_partitions_limit and "TOO_MANY_OPEN_PARTITIONS" in str(e)
176-
else False
177-
if "Query timeout" in str(e)
178-
else True
175+
not (catch_partitions_limit and "TOO_MANY_OPEN_PARTITIONS" in str(e))
176+
and "Query timeout" not in str(e)
179177
)
180178
),
181179
stop=stop_after_attempt(self._retry_config.attempt),

0 commit comments

Comments
 (0)