def get_tables(self, database='default', table_names='*', table_types=None): if self.server_name == 'beeswax': identifier = self.to_matching_wildcard(table_names) else: identifier = None tables = self.client.get_tables(database, identifier, table_types) if len(tables) <= APPLY_NATURAL_SORT_MAX.get(): tables = apply_natural_sort(tables) return tables
def get_tables_meta(self, database="default", table_names="*", table_types=None): if self.server_name == "beeswax": identifier = self.to_matching_wildcard(table_names) else: identifier = None tables = self.client.get_tables_meta(database, identifier, table_types) if len(tables) <= APPLY_NATURAL_SORT_MAX.get(): tables = apply_natural_sort(tables, key="name") return tables
def get_databases(self, database_names='*'): if database_names != '*': database_names = self.to_matching_wildcard(database_names) databases = self.client.get_databases(schemaName=database_names) if len(databases) <= APPLY_NATURAL_SORT_MAX.get(): databases = apply_natural_sort(databases) return databases
def get_tables_meta(self, database='default', table_names='*', table_types=None): database = database.lower() # Impala is case sensitive if self.server_name == 'beeswax': identifier = self.to_matching_wildcard(table_names) else: identifier = None tables = self.client.get_tables_meta(database, identifier, table_types) if len(tables) <= APPLY_NATURAL_SORT_MAX.get(): tables = apply_natural_sort(tables, key='name') return tables
def get_databases(self, database_names='*'): identifier = self.to_matching_wildcard(database_names) hql = "SHOW DATABASES LIKE '%s'" % (identifier) # self.client.get_databases() is too slow query = hql_query(hql) timeout = SERVER_CONN_TIMEOUT.get() handle = self.execute_and_wait(query, timeout_sec=timeout) if handle: result = self.fetch(handle, rows=5000) self.close(handle) databases = [name for database in result.rows() for name in database] if len(databases) <= APPLY_NATURAL_SORT_MAX.get(): databases = apply_natural_sort(databases) return databases else: return []
def get_tables(self, database='default', table_names='*'): identifier = self.to_matching_wildcard(table_names) hql = "SHOW TABLES IN `%s` '%s'" % (database, identifier) # self.client.get_tables(database, table_names) is too slow query = hql_query(hql) timeout = SERVER_CONN_TIMEOUT.get() handle = self.execute_and_wait(query, timeout_sec=timeout) if handle: result = self.fetch(handle, rows=5000) self.close(handle) tables = [name for table in result.rows() for name in table] if len(tables) <= APPLY_NATURAL_SORT_MAX.get(): tables = apply_natural_sort(tables) return tables else: return []
def get_tables(self, database='default', table_names='*'): identifier = self.to_matching_wildcard(table_names) identifier = "'%s'" % identifier if identifier != '*' else '' # Filter not supported in SparkSql hql = "SHOW TABLES IN `%s` %s" % (database, identifier) # self.client.get_tables(database, table_names) is too slow query = hql_query(hql) timeout = SERVER_CONN_TIMEOUT.get() handle = self.execute_and_wait(query, timeout_sec=timeout) if handle: result = self.fetch(handle, rows=5000) self.close(handle) tables = [table[0] for table in result.rows()] # We only keep the first column as the name, SparkSql returns multiple columns if len(tables) <= APPLY_NATURAL_SORT_MAX.get(): tables = apply_natural_sort(tables) return tables else: return []
def get_tables(self, database='default', table_names='*'): identifier = self.to_matching_wildcard(table_names) identifier = "'%s'" % identifier if identifier != '*' else '' # Filter not supported in SparkSql hql = "SHOW TABLES IN `%s` %s" % ( database, identifier ) # self.client.get_tables(database, table_names) is too slow query = hql_query(hql) timeout = SERVER_CONN_TIMEOUT.get() handle = self.execute_and_wait(query, timeout_sec=timeout) if handle: result = self.fetch(handle, rows=5000) self.close(handle) tables = [ table[0] for table in result.rows() ] # We only keep the first column as the name, SparkSql returns multiple columns if len(tables) <= APPLY_NATURAL_SORT_MAX.get(): tables = apply_natural_sort(tables) return tables else: return []
def get_tables_meta(self, database='default', table_names='*'): identifier = self.to_matching_wildcard(table_names) tables = self.client.get_tables_meta(database, identifier) if len(tables) <= APPLY_NATURAL_SORT_MAX.get(): tables = apply_natural_sort(tables, key='name') return tables