aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndy Lu <andy@stitchdata.com>2021-02-18 09:01:04 -0600
committerGitHub <noreply@github.com>2021-02-18 09:01:04 -0600
commit80f97522abf03503586419b9ebd2aae4213f8f50 (patch)
tree4bf35a2dda35e2ddf44a769019d3f4a75c21257e
parent1080d5ece1d90464c448c7e3f8dc58410fad0601 (diff)
downloadtap-google-sheets-80f97522abf03503586419b9ebd2aae4213f8f50.tar.gz
tap-google-sheets-80f97522abf03503586419b9ebd2aae4213f8f50.tar.zst
tap-google-sheets-80f97522abf03503586419b9ebd2aae4213f8f50.zip
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
-rw-r--r--tap_google_sheets/schema.py23
1 files 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):
152 else: 152 else:
153 # Interesting - order in the anyOf makes a difference. 153 # Interesting - order in the anyOf makes a difference.
154 # Number w/ multipleOf must be listed last, otherwise errors occur. 154 # Number w/ multipleOf must be listed last, otherwise errors occur.
155 col_properties = { 155 col_properties = {'type': 'number', 'multipleOf': 1e-15}
156 'anyOf': [
157 {
158 'type': 'null'
159 },
160 {
161 'type': 'number',
162 'multipleOf': 1e-15
163 },
164 {
165 'type': 'string'
166 }
167 ]
168 }
169 column_gs_type = 'numberType' 156 column_gs_type = 'numberType'
170 # Catch-all to deal with other types and set to string 157 # Catch-all to deal with other types and set to string
171 # column_effective_value_type: formulaValue, errorValue, or other 158 # column_effective_value_type: formulaValue, errorValue, or other
@@ -205,6 +192,14 @@ def get_sheet_schema_columns(sheet):
205 } 192 }
206 columns.append(column) 193 columns.append(column)
207 194
195 if column_gs_type in {'numberType.DATE_TIME', 'numberType.DATE', 'numberType.TIME', 'numberType'}:
196 col_properties = {
197 'anyOf': [
198 col_properties,
199 {'type': ['null', 'string']}
200 ]
201 }
202
208 sheet_json_schema['properties'][column_name] = col_properties 203 sheet_json_schema['properties'][column_name] = col_properties
209 204
210 prior_header = column_name 205 prior_header = column_name