Beispiel #1
0
    def _wait_to_finish(self):
        # Prior to IMPALA-1633 GetOperationStatus does not populate errorMessage
        # in case of failure. If not populated, queries that return results
        # can get a failure description with a further call to FetchResults rpc.
        loop_start = time.time()
        while True:
            req = TGetOperationStatusReq(
                operationHandle=self._last_operation.handle)
            resp = self._last_operation._rpc('GetOperationStatus', req)
            operation_state = TOperationState._VALUES_TO_NAMES[
                resp.operationState]

            log.debug('_wait_to_finish: waited %s seconds so far',
                      time.time() - loop_start)
            if self._op_state_is_error(operation_state):
                if resp.errorMessage:
                    raise OperationalError(resp.errorMessage)
                else:
                    if self.fetch_error and self.has_result_set:
                        self._last_operation_active = False
                        self._last_operation.fetch()
                    else:
                        raise OperationalError("Operation is in ERROR_STATE")
            if not self._op_state_is_executing(operation_state):
                break
            time.sleep(self._get_sleep_interval(loop_start))
Beispiel #2
0
    def get_table_schema(self, table_name, database_name=None):
        if database_name is None:
            database_name = '.*'

        def op():
            self._last_operation_string = "RPC_DESCRIBE_TABLE"
            self._last_operation = self.session.get_table_schema(
                table_name, database_name)

        self._execute_async(op)
        self._wait_to_finish()
        results = self.fetchall()
        if len(results) == 0:
            # TODO: the error raised here should be different
            raise OperationalError("no schema results for table %s.%s" %
                                   (database_name, table_name))
        # check that results are derived from a unique table
        tables = set()
        for col in results:
            tables.add((col[1], col[2]))
        if len(tables) > 1:
            # TODO: the error raised here should be different
            raise ProgrammingError("db: %s, table: %s is not unique" %
                                   (database_name, table_name))
        return [(r[3], r[5]) for r in results]
Beispiel #3
0
 def _wait_to_finish(self):
     loop_start = time.time()
     while True:
         operation_state = rpc.get_query_state(self.service,
                                                   self._last_operation_handle)
         if operation_state == self.query_state["FINISHED"]:
             break
         elif operation_state == self.query_state["EXCEPTION"]:
             raise OperationalError(self.get_log())
         time.sleep(self._get_sleep_interval(loop_start))
Beispiel #4
0
 def _wait_to_finish(self):
     loop_start = time.time()
     while True:
         operation_state = rpc.get_operation_status(self.service,
                 self._last_operation_handle)
         if operation_state == 'ERROR_STATE':
             raise OperationalError("Operation is in ERROR_STATE")
         if operation_state not in ['INITIALIZED_STATE', 'RUNNING_STATE']:
             break
         # I'm in INITIALIZED_STATE or RUNNING_STATE so hang out
         time.sleep(self._get_sleep_interval(loop_start))
Beispiel #5
0
    def _wait_to_finish(self):
        loop_start = time.time()
        while True:
            operation_state = self._last_operation.get_status()

            log.debug('_wait_to_finish: waited %s seconds so far',
                      time.time() - loop_start)
            if self._op_state_is_error(operation_state):
                raise OperationalError("Operation is in ERROR_STATE")
            if not self._op_state_is_executing(operation_state):
                break
            time.sleep(self._get_sleep_interval(loop_start))