Waits for the Redshift statement to finish. Raises RedshiftQueryError if the statement didn't succeed. We use exponential backoff for checking the query state until it's not running. The backoff starts with 0.1 seconds and doubles exponentially until reaching 30 seconds, at which point the
(redshift_data_client, statement: dict)
| 127 | reraise=True, |
| 128 | ) |
| 129 | def wait_for_redshift_statement(redshift_data_client, statement: dict) -> None: |
| 130 | """Waits for the Redshift statement to finish. Raises RedshiftQueryError if the statement didn't succeed. |
| 131 | |
| 132 | We use exponential backoff for checking the query state until it's not running. The backoff starts with |
| 133 | 0.1 seconds and doubles exponentially until reaching 30 seconds, at which point the backoff is fixed. |
| 134 | |
| 135 | Args: |
| 136 | redshift_data_client: Redshift Data API Service client |
| 137 | statement: The redshift statement to wait for (result of execute_redshift_statement) |
| 138 | |
| 139 | Returns: None |
| 140 | |
| 141 | """ |
| 142 | desc = redshift_data_client.describe_statement(Id=statement["Id"]) |
| 143 | if desc["Status"] in ("SUBMITTED", "STARTED", "PICKED"): |
| 144 | raise RedshiftStatementNotFinishedError # Retry |
| 145 | if desc["Status"] != "FINISHED": |
| 146 | raise RedshiftQueryError(desc) # Don't retry. Raise exception. |
| 147 | |
| 148 | |
| 149 | def execute_redshift_statement( |
no test coverage detected