From 80f97522abf03503586419b9ebd2aae4213f8f50 Mon Sep 17 00:00:00 2001 From: Andy Lu Date: Thu, 18 Feb 2021 09:01:04 -0600 Subject: [PATCH] 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 --- tap_google_sheets/schema.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) 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 -- 2.41.0