Skip to content
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

fix: google.cloud.gcp_bigquery_table clustering fields #652

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/fix-bigquery-table-create-clustering.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- gcp_bigquery_table - properly handle BigQuery table clustering fields
19 changes: 17 additions & 2 deletions plugins/modules/gcp_bigquery_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ def resource_to_request(module):
request = {
u'kind': 'bigquery#table',
u'tableReference': TableTablereference(module.params.get('table_reference', {}), module).to_request(),
u'clustering': module.params.get('clustering'),
u'clustering': TableClustering(module.params.get('clustering', {}), module).to_request(),
u'description': module.params.get('description'),
u'friendlyName': module.params.get('friendly_name'),
u'labels': module.params.get('labels'),
Expand Down Expand Up @@ -1247,7 +1247,7 @@ def is_different(module, response):
def response_to_hash(module, response):
return {
u'tableReference': TableTablereference(response.get(u'tableReference', {}), module).from_response(),
u'clustering': response.get(u'clustering'),
u'clustering': TableClustering(response.get(u'clustering', {}), module).from_response(),
u'creationTime': response.get(u'creationTime'),
u'description': response.get(u'description'),
u'friendlyName': response.get(u'friendlyName'),
Expand Down Expand Up @@ -1713,5 +1713,20 @@ def _response_from_item(self, item):
)


class TableClustering(object):
def __init__(self, request, module):
self.module = module
if request:
self.request = request
else:
self.request = {}

def to_request(self):
return remove_nones_from_dict({'fields': self.request})

def from_response(self):
return remove_nones_from_dict({'fields': self.request})


if __name__ == '__main__':
main()
Loading