Merge pull request #652 from gomesfernandes/fix/bigquery-clustering-fields

fix: google.cloud.gcp_bigquery_table clustering fields
This commit is contained in:
Chris Hawk 2024-11-11 17:05:12 -08:00 committed by GitHub
commit 5a395e234f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 2 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- gcp_bigquery_table - properly handle BigQuery table clustering fields

View file

@ -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'),
@ -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'),
@ -1713,5 +1713,20 @@ class TableColumnsArray(object):
)
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()