-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Athena] Fix: missing databases (apply pagination) #2503
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
16e8849
adding paginator on databases in glue
ialeinikov a4a8d7d
reduce number of nested loops
ialeinikov f64dbae
fixing indentation
ialeinikov 0ebd876
double for-loop instead of generator
ialeinikov 306643b
removing unused generator
ialeinikov ce86859
Merge branch 'master' into master
arikfr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,18 +125,20 @@ def __get_schema_from_glue(self): | |
region_name=self.configuration['region'] | ||
) | ||
schema = {} | ||
paginator = client.get_paginator('get_tables') | ||
database_paginator = client.get_paginator('get_databases') | ||
table_paginator = client.get_paginator('get_tables') | ||
databases = (database for databases in database_paginator.paginate() | ||
for database in databases['DatabaseList']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for making the change into two for-loops. But don't we need to remove lines 130-131 now? |
||
|
||
for database in client.get_databases()['DatabaseList']: | ||
iterator = paginator.paginate(DatabaseName=database['Name']) | ||
for database in databases: | ||
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['PartitionKeys']: | ||
schema[table_name]['columns'].append(partition['Name']) | ||
|
||
return schema.values() | ||
|
||
def get_schema(self, get_stats=False): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something in these 2 lines doesn't look right. are you sure this is what you wanted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to paginate over both databases and tables.
A database paginator returns a list of lists, in the l#130 I flatten it inside a generator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would suffice to just indent the double for-loops differently to make it more clear?