From: Andy Lu Date: Thu, 18 Feb 2021 15:01:04 +0000 (-0600) Subject: Allow all schemas to fall back to a string value (#25) X-Git-Tag: v1.1.0~1 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=80f97522abf03503586419b9ebd2aae4213f8f50;p=github%2Ffretlink%2Ftap-google-sheets.git Allow all schemas to fall back to a string value (#25) * Allow all schemas to fall back to a string value * Only update 'numberType.DATE_TIME', 'numberType.DATE', 'numberType.TIME' fields to have an anyOf * Bad Refactor: numberType needs anyOf * Fix indenting --- diff --git a/tap_google_sheets/schema.py b/tap_google_sheets/schema.py index fcaccf9..13e595a 100644 --- a/tap_google_sheets/schema.py +++ b/tap_google_sheets/schema.py @@ -152,20 +152,7 @@ def get_sheet_schema_columns(sheet): else: # Interesting - order in the anyOf makes a difference. # Number w/ multipleOf must be listed last, otherwise errors occur. - col_properties = { - 'anyOf': [ - { - 'type': 'null' - }, - { - 'type': 'number', - 'multipleOf': 1e-15 - }, - { - 'type': 'string' - } - ] - } + col_properties = {'type': 'number', 'multipleOf': 1e-15} column_gs_type = 'numberType' # Catch-all to deal with other types and set to string # column_effective_value_type: formulaValue, errorValue, or other @@ -205,6 +192,14 @@ def get_sheet_schema_columns(sheet): } columns.append(column) + if column_gs_type in {'numberType.DATE_TIME', 'numberType.DATE', 'numberType.TIME', 'numberType'}: + col_properties = { + 'anyOf': [ + col_properties, + {'type': ['null', 'string']} + ] + } + sheet_json_schema['properties'][column_name] = col_properties prior_header = column_name