示例#1
0
 def test_init(self):
     actual = AthenaQueryExecution(ATHENA_QUERY_EXECUTION_RESPONSE)
     self.assertEqual(actual.database, "test_database")
     self.assertEqual(actual.query_id,
                      "12345678-90ab-cdef-1234-567890abcdef")
     self.assertEqual(actual.query, "SELECT * FROM test_table")
     self.assertEqual(actual.statement_type, "DML")
     self.assertEqual(actual.state, "SUCCEEDED")
     self.assertEqual(actual.state_change_reason, "test_reason")
     self.assertEqual(actual.completion_date_time,
                      datetime(2019, 1, 1, 0, 0, 0))
     self.assertEqual(actual.submission_date_time,
                      datetime(2019, 1, 1, 0, 0, 0))
     self.assertEqual(actual.data_scanned_in_bytes, 1234567890)
     self.assertEqual(actual.execution_time_in_millis, 1234567890)
     self.assertEqual(actual.engine_execution_time_in_millis, 1234567890)
     self.assertEqual(actual.query_queue_time_in_millis, 1234567890)
     self.assertEqual(actual.total_execution_time_in_millis, 1234567890)
     self.assertEqual(actual.query_planning_time_in_millis, 1234567890)
     self.assertEqual(actual.service_processing_time_in_millis, 1234567890)
     self.assertEqual(actual.output_location, "s3://bucket/path/to/")
     self.assertEqual(actual.data_manifest_location, "s3://bucket/path/to/")
     self.assertEqual(actual.encryption_option, "test_encryption_option")
     self.assertEqual(actual.kms_key, "test_kms_key")
     self.assertEqual(actual.work_group, "test_work_group")
示例#2
0
 def _get_query_execution(self, query_id):
     request = {'QueryExecutionId': query_id}
     try:
         response = retry_api_call(
             self._connection.client.get_query_execution,
             config=self._retry_config,
             logger=_logger,
             **request)
     except Exception as e:
         _logger.exception('Failed to get query execution.')
         raise_from(OperationalError(*e.args), e)
     else:
         return AthenaQueryExecution(response)
示例#3
0
 def _get_query_execution(self, query_id: str) -> AthenaQueryExecution:
     request = {"QueryExecutionId": query_id}
     try:
         response = retry_api_call(
             self._connection.client.get_query_execution,
             config=self._retry_config,
             logger=_logger,
             **request)
     except Exception as e:
         _logger.exception("Failed to get query execution.")
         raise OperationalError(*e.args) from e
     else:
         return AthenaQueryExecution(response)
示例#4
0
文件: common.py 项目: ivssh/PyAthena
 def _query_execution(self, query_id):
     request = {'QueryExecutionId': query_id}
     try:
         response = retry_api_call(self._connection.get_query_execution,
                                   exceptions=self.retry_exceptions,
                                   attempt=self.retry_attempt,
                                   multiplier=self.retry_multiplier,
                                   max_delay=self.retry_max_delay,
                                   exp_base=self.retry_exponential_base,
                                   logger=_logger,
                                   **request)
     except Exception as e:
         _logger.exception('Failed to get query execution.')
         raise_from(OperationalError(*e.args), e)
     else:
         return AthenaQueryExecution(response)
示例#5
0
 def _batch_get_query_execution(
     self, query_ids: List[str]
 ) -> List[AthenaQueryExecution]:
     try:
         response = retry_api_call(
             self.connection._client.batch_get_query_execution,
             config=self._retry_config,
             logger=_logger,
             QueryExecutionIds=query_ids,
         )
     except Exception as e:
         _logger.exception("Failed to batch get query execution.")
         raise OperationalError(*e.args) from e
     else:
         return [
             AthenaQueryExecution({"QueryExecution": r})
             for r in response.get("QueryExecutions", [])
         ]
示例#6
0
 def test_init(self):
     actual = AthenaQueryExecution(ATHENA_QUERY_EXECUTION_RESPONSE)
     self.assertEqual(actual.database, 'test_database')
     self.assertEqual(actual.query_id,
                      '12345678-90ab-cdef-1234-567890abcdef')
     self.assertEqual(actual.query, 'SELECT * FROM test_table')
     self.assertEqual(actual.statement_type, 'DML')
     self.assertEqual(actual.state, 'SUCCEEDED')
     self.assertEqual(actual.state_change_reason, 'test_reason')
     self.assertEqual(actual.completion_date_time,
                      datetime(2019, 1, 1, 0, 0, 0))
     self.assertEqual(actual.submission_date_time,
                      datetime(2019, 1, 1, 0, 0, 0))
     self.assertEqual(actual.data_scanned_in_bytes, 1234567890)
     self.assertEqual(actual.execution_time_in_millis, 1234567890)
     self.assertEqual(actual.output_location, 's3://bucket/path/to/')
     self.assertEqual(actual.encryption_option, 'test_encryption_option')
     self.assertEqual(actual.kms_key, 'test_kms_key')
     self.assertEqual(actual.work_group, 'test_work_group')
示例#7
0
 def test_init(self):
     actual = AthenaQueryExecution(ATHENA_QUERY_EXECUTION_RESPONSE)
     assert actual.database == "test_database"
     assert actual.query_id, "12345678-90ab-cdef-1234-567890abcdef"
     assert actual.query == "SELECT * FROM test_table"
     assert actual.statement_type == "DML"
     assert actual.state == "SUCCEEDED"
     assert actual.state_change_reason == "test_reason"
     assert actual.completion_date_time == datetime(2019, 1, 1, 0, 0, 0)
     assert actual.submission_date_time == datetime(2019, 1, 1, 0, 0, 0)
     assert actual.data_scanned_in_bytes == 1234567890
     assert actual.engine_execution_time_in_millis == 234567890
     assert actual.query_queue_time_in_millis == 34567890
     assert actual.total_execution_time_in_millis == 4567890
     assert actual.query_planning_time_in_millis == 567890
     assert actual.service_processing_time_in_millis == 67890
     assert actual.output_location == "s3://bucket/path/to/"
     assert actual.data_manifest_location == "s3://bucket/path/to/"
     assert actual.encryption_option == "test_encryption_option"
     assert actual.kms_key == "test_kms_key"
     assert actual.work_group == "test_work_group"