diff --git a/lib/trino/client/statement_client.rb b/lib/trino/client/statement_client.rb index 1f2c94e6..178922ba 100644 --- a/lib/trino/client/statement_client.rb +++ b/lib/trino/client/statement_client.rb @@ -262,9 +262,11 @@ def cancel_leaf_stage end def close - return unless running? - - @state = :client_aborted + return if finished? || query_failed? || client_aborted? + + if running? + @state = :client_aborted + end begin if uri = @results.next_uri