class BeeswaxConnection(ImpalaConnection): def __init__(self, host_port, use_kerberos=False, user=None, password=None, use_ssl=False): self.__beeswax_client = ImpalaBeeswaxClient(host_port, use_kerberos, user=user, password=password, use_ssl=use_ssl) self.__host_port = host_port self.QUERY_STATES = self.__beeswax_client.query_states def set_configuration_option(self, name, value): # Only set the option if it's not already set to the same value. if self.__beeswax_client.get_query_option(name) != value: LOG.info('SET %s=%s;' % (name, value)) self.__beeswax_client.set_query_option(name, value) def get_default_configuration(self): result = {} for item in self.__beeswax_client.get_default_configuration(): result[item.key] = item.value return result def clear_configuration(self): self.__beeswax_client.clear_query_options() # A hook in conftest sets tests.common.current_node. if hasattr(tests.common, "current_node"): self.set_configuration_option("client_identifier", tests.common.current_node) def connect(self): LOG.info("-- connecting to: %s" % self.__host_port) self.__beeswax_client.connect() # TODO: rename to close_connection def close(self): LOG.info("-- closing connection to: %s" % self.__host_port) self.__beeswax_client.close_connection() def close_query(self, operation_handle): LOG.info("-- closing query for operation handle: %s" % operation_handle) self.__beeswax_client.close_query(operation_handle.get_handle()) def close_dml(self, operation_handle): LOG.info("-- closing DML query for operation handle: %s" % operation_handle) self.__beeswax_client.close_dml(operation_handle.get_handle()) def execute(self, sql_stmt, user=None): LOG.info("-- executing against %s\n" % (self.__host_port)) log_sql_stmt(sql_stmt) return self.__beeswax_client.execute(sql_stmt, user=user) def execute_async(self, sql_stmt, user=None): LOG.info("-- executing async: %s\n" % (self.__host_port)) log_sql_stmt(sql_stmt) beeswax_handle = self.__beeswax_client.execute_query_async(sql_stmt, user=user) return OperationHandle(beeswax_handle, sql_stmt) def cancel(self, operation_handle): LOG.info("-- canceling operation: %s" % operation_handle) return self.__beeswax_client.cancel_query( operation_handle.get_handle()) def get_state(self, operation_handle): LOG.info("-- getting state for operation: %s" % operation_handle) return self.__beeswax_client.get_state(operation_handle.get_handle()) def state_is_finished(self, operation_handle): LOG.info("-- checking finished state for operation: {0}".format( operation_handle)) return self.get_state( operation_handle) == self.QUERY_STATES["FINISHED"] def get_exec_summary(self, operation_handle): LOG.info("-- getting exec summary operation: %s" % operation_handle) return self.__beeswax_client.get_exec_summary( operation_handle.get_handle()) def get_runtime_profile(self, operation_handle): LOG.info("-- getting runtime profile operation: %s" % operation_handle) return self.__beeswax_client.get_runtime_profile( operation_handle.get_handle()) def wait_for_finished_timeout(self, operation_handle, timeout): LOG.info("-- waiting for query to reach FINISHED state: %s" % operation_handle) return self.__beeswax_client.wait_for_finished_timeout( operation_handle.get_handle(), timeout) def wait_for_admission_control(self, operation_handle): LOG.info( "-- waiting for completion of the admission control processing of the " "query: %s" % operation_handle) return self.__beeswax_client.wait_for_admission_control( operation_handle.get_handle()) def get_admission_result(self, operation_handle): LOG.info("-- getting the admission result: %s" % operation_handle) return self.__beeswax_client.get_admission_result( operation_handle.get_handle()) def get_log(self, operation_handle): LOG.info("-- getting log for operation: %s" % operation_handle) return self.__beeswax_client.get_log( operation_handle.get_handle().log_context) def fetch(self, sql_stmt, operation_handle, max_rows=-1): LOG.info("-- fetching results from: %s" % operation_handle) return self.__beeswax_client.fetch_results( sql_stmt, operation_handle.get_handle(), max_rows)
class BeeswaxConnection(ImpalaConnection): def __init__(self, host_port, use_kerberos=False, user=None, password=None, use_ssl=False): self.__beeswax_client = ImpalaBeeswaxClient(host_port, use_kerberos, user=user, password=password, use_ssl=use_ssl) self.__host_port = host_port self.QUERY_STATES = self.__beeswax_client.query_states def set_configuration_option(self, name, value): # Only set the option if it's not already set to the same value. if self.__beeswax_client.get_query_option(name) != value: LOG.info('SET %s=%s;' % (name, value)) self.__beeswax_client.set_query_option(name, value) def get_configuration(self): return self.__beeswax_client.get_query_options def set_configuration(self, config_option_dict): assert config_option_dict is not None, "config_option_dict cannot be None" self.clear_configuration() for name, value in config_option_dict.iteritems(): self.set_configuration_option(name, value) def clear_configuration(self): self.__beeswax_client.clear_query_options() def connect(self): LOG.info("-- connecting to: %s" % self.__host_port) self.__beeswax_client.connect() # TODO: rename to close_connection def close(self): LOG.info("-- closing connection to: %s" % self.__host_port) self.__beeswax_client.close_connection() def close_query(self, operation_handle): LOG.info("-- closing query for operation handle: %s" % operation_handle) self.__beeswax_client.close_query(operation_handle.get_handle()) def execute(self, sql_stmt): LOG.info("-- executing against %s\n%s;\n" % (self.__host_port, sql_stmt)) return self.__beeswax_client.execute(sql_stmt) def execute_async(self, sql_stmt): LOG.info("-- executing async: %s\n%s;\n" % (self.__host_port, sql_stmt)) return OperationHandle(self.__beeswax_client.execute_query_async(sql_stmt)) def cancel(self, operation_handle): LOG.info("-- canceling operation: %s" % operation_handle) return self.__beeswax_client.cancel_query(operation_handle.get_handle()) def get_state(self, operation_handle): LOG.info("-- getting state for operation: %s" % operation_handle) return self.__beeswax_client.get_state(operation_handle.get_handle()) def get_runtime_profile(self, operation_handle): LOG.info("-- getting runtime profile operation: %s" % operation_handle) return self.__beeswax_client.get_runtime_profile(operation_handle.get_handle()) def get_log(self, operation_handle): LOG.info("-- getting log for operation: %s" % operation_handle) return self.__beeswax_client.get_log(operation_handle.get_handle()) def refresh(self): """Invalidate the Impalad catalog""" return self.execute("invalidate metadata") def invalidate_table(self, table_name): """Invalidate a specific table from the catalog""" return self.execute("invalidate metadata %s" % (table_name)) def refresh_table(self, db_name, table_name): """Refresh a specific table from the catalog""" return self.execute("refresh %s.%s" % (db_name, table_name)) def fetch(self, sql_stmt, operation_handle, max_rows = -1): LOG.info("-- fetching results from: %s" % operation_handle) return self.__beeswax_client.fetch_results( sql_stmt, operation_handle.get_handle(), max_rows)
class BeeswaxConnection(ImpalaConnection): def __init__(self, host_port, use_kerberos=False, user=None, password=None, use_ssl=False): self.__beeswax_client = ImpalaBeeswaxClient(host_port, use_kerberos, user=user, password=password, use_ssl=use_ssl) self.__host_port = host_port self.QUERY_STATES = self.__beeswax_client.query_states def set_configuration_option(self, name, value): # Only set the option if it's not already set to the same value. if self.__beeswax_client.get_query_option(name) != value: LOG.info('SET %s=%s;' % (name, value)) self.__beeswax_client.set_query_option(name, value) def get_configuration(self): return self.__beeswax_client.get_query_options def set_configuration(self, config_option_dict): assert config_option_dict is not None, "config_option_dict cannot be None" self.clear_configuration() for name, value in config_option_dict.iteritems(): self.set_configuration_option(name, value) def clear_configuration(self): self.__beeswax_client.clear_query_options() def connect(self): LOG.info("-- connecting to: %s" % self.__host_port) self.__beeswax_client.connect() # TODO: rename to close_connection def close(self): LOG.info("-- closing connection to: %s" % self.__host_port) self.__beeswax_client.close_connection() def close_query(self, operation_handle): LOG.info("-- closing query for operation handle: %s" % operation_handle) self.__beeswax_client.close_query(operation_handle.get_handle()) def execute(self, sql_stmt): LOG.info("-- executing against %s\n%s;\n" % (self.__host_port, sql_stmt)) return self.__beeswax_client.execute(sql_stmt) def execute_async(self, sql_stmt): LOG.info("-- executing async: %s\n%s;\n" % (self.__host_port, sql_stmt)) return OperationHandle( self.__beeswax_client.execute_query_async(sql_stmt)) def cancel(self, operation_handle): LOG.info("-- canceling operation: %s" % operation_handle) return self.__beeswax_client.cancel_query( operation_handle.get_handle()) def get_state(self, operation_handle): LOG.info("-- getting state for operation: %s" % operation_handle) return self.__beeswax_client.get_state(operation_handle.get_handle()) def get_runtime_profile(self, operation_handle): LOG.info("-- getting runtime profile operation: %s" % operation_handle) return self.__beeswax_client.get_runtime_profile( operation_handle.get_handle()) def get_log(self, operation_handle): LOG.info("-- getting log for operation: %s" % operation_handle) return self.__beeswax_client.get_log(operation_handle.get_handle()) def refresh(self): """Invalidate the Impalad catalog""" return self.execute("invalidate metadata") def invalidate_table(self, table_name): """Invalidate a specific table from the catalog""" return self.execute("invalidate metadata %s" % (table_name)) def refresh_table(self, db_name, table_name): """Refresh a specific table from the catalog""" return self.execute("refresh %s.%s" % (db_name, table_name)) def fetch(self, sql_stmt, operation_handle, max_rows=-1): LOG.info("-- fetching results from: %s" % operation_handle) return self.__beeswax_client.fetch_results( sql_stmt, operation_handle.get_handle(), max_rows)
class BeeswaxConnection(ImpalaConnection): def __init__(self, host_port, use_kerberos=False, user=None, password=None, use_ssl=False): self.__beeswax_client = ImpalaBeeswaxClient(host_port, use_kerberos, user=user, password=password, use_ssl=use_ssl) self.__host_port = host_port self.QUERY_STATES = self.__beeswax_client.query_states def set_configuration_option(self, name, value): # Only set the option if it's not already set to the same value. if self.__beeswax_client.get_query_option(name) != value: LOG.info('SET %s=%s;' % (name, value)) self.__beeswax_client.set_query_option(name, value) def get_default_configuration(self): result = {} for item in self.__beeswax_client.get_default_configuration(): result[item.key] = item.value return result def clear_configuration(self): self.__beeswax_client.clear_query_options() # A hook in conftest sets tests.common.current_node. if hasattr(tests.common, "current_node"): self.set_configuration_option("client_identifier", tests.common.current_node) def connect(self): LOG.info("-- connecting to: %s" % self.__host_port) self.__beeswax_client.connect() # TODO: rename to close_connection def close(self): LOG.info("-- closing connection to: %s" % self.__host_port) self.__beeswax_client.close_connection() def close_query(self, operation_handle): LOG.info("-- closing query for operation handle: %s" % operation_handle) self.__beeswax_client.close_query(operation_handle.get_handle()) def execute(self, sql_stmt, user=None): LOG.info("-- executing against %s\n%s;\n" % (self.__host_port, sql_stmt)) return self.__beeswax_client.execute(sql_stmt, user=user) def execute_async(self, sql_stmt, user=None): LOG.info("-- executing async: %s\n%s;\n" % (self.__host_port, sql_stmt)) beeswax_handle = self.__beeswax_client.execute_query_async(sql_stmt, user=user) return OperationHandle(beeswax_handle, sql_stmt) def cancel(self, operation_handle): LOG.info("-- canceling operation: %s" % operation_handle) return self.__beeswax_client.cancel_query(operation_handle.get_handle()) def get_state(self, operation_handle): LOG.info("-- getting state for operation: %s" % operation_handle) return self.__beeswax_client.get_state(operation_handle.get_handle()) def get_exec_summary(self, operation_handle): LOG.info("-- getting exec summary operation: %s" % operation_handle) return self.__beeswax_client.get_exec_summary(operation_handle.get_handle()) def get_runtime_profile(self, operation_handle): LOG.info("-- getting runtime profile operation: %s" % operation_handle) return self.__beeswax_client.get_runtime_profile(operation_handle.get_handle()) def wait_for_finished_timeout(self, operation_handle, timeout): LOG.info("-- waiting for query to reach FINISHED state: %s" % operation_handle) return self.__beeswax_client.wait_for_finished_timeout( operation_handle.get_handle(), timeout) def wait_for_admission_control(self, operation_handle): LOG.info("-- waiting for completion of the admission control processing of the " "query: %s" % operation_handle) return self.__beeswax_client.wait_for_admission_control(operation_handle.get_handle()) def get_admission_result(self, operation_handle): LOG.info("-- getting the admission result: %s" % operation_handle) return self.__beeswax_client.get_admission_result(operation_handle.get_handle()) def get_log(self, operation_handle): LOG.info("-- getting log for operation: %s" % operation_handle) return self.__beeswax_client.get_log(operation_handle.get_handle()) def fetch(self, sql_stmt, operation_handle, max_rows = -1): LOG.info("-- fetching results from: %s" % operation_handle) return self.__beeswax_client.fetch_results( sql_stmt, operation_handle.get_handle(), max_rows)