diff --git a/redash/query_runner/athena.py b/redash/query_runner/athena.py index e7f1bb4ad5..67d7e19fff 100644 --- a/redash/query_runner/athena.py +++ b/redash/query_runner/athena.py @@ -121,18 +121,20 @@ def __get_schema_from_glue(self): region_name=self.configuration['region'] ) schema = {} - paginator = client.get_paginator('get_tables') - - for database in client.get_databases()['DatabaseList']: - iterator = paginator.paginate(DatabaseName=database['Name']) - for table in iterator.search('TableList[]'): - table_name = '%s.%s' % (database['Name'], table['Name']) - if table_name not in schema: - column = [columns['Name'] for columns in table['StorageDescriptor']['Columns']] - schema[table_name] = {'name': table_name, 'columns': column} - for partition in table.get('PartitionKeys', []): - schema[table_name]['columns'].append(partition['Name']) + database_paginator = client.get_paginator('get_databases') + table_paginator = client.get_paginator('get_tables') + + for databases in database_paginator.paginate(): + for database in databases['DatabaseList']: + iterator = table_paginator.paginate(DatabaseName=database['Name']) + for table in iterator.search('TableList[]'): + table_name = '%s.%s' % (database['Name'], table['Name']) + if table_name not in schema: + column = [columns['Name'] for columns in table['StorageDescriptor']['Columns']] + schema[table_name] = {'name': table_name, 'columns': column} + for partition in table.get('PartitionKeys', []): + schema[table_name]['columns'].append(partition['Name']) return schema.values() def get_schema(self, get_stats=False):