aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndy Lu <andy@stitchdata.com>2021-02-08 22:20:48 +0000
committerAndy Lu <andy@stitchdata.com>2021-02-08 22:20:48 +0000
commit6d2902807908e47d67f2fb69eda6458c2622880c (patch)
tree357318bd0b62b2eff7667711f12ae027d9a4e1a2
parent1080d5ece1d90464c448c7e3f8dc58410fad0601 (diff)
downloadtap-google-sheets-6d2902807908e47d67f2fb69eda6458c2622880c.tar.gz
tap-google-sheets-6d2902807908e47d67f2fb69eda6458c2622880c.tar.zst
tap-google-sheets-6d2902807908e47d67f2fb69eda6458c2622880c.zip
Add transform function to drop date of time fields
-rw-r--r--tap_google_sheets/sync.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tap_google_sheets/sync.py b/tap_google_sheets/sync.py
index 26c2d19..986c6ca 100644
--- a/tap_google_sheets/sync.py
+++ b/tap_google_sheets/sync.py
@@ -64,6 +64,15 @@ def write_bookmark(state, stream, value):
64 singer.write_state(state) 64 singer.write_state(state)
65 65
66 66
67def drop_date_on_time(schema, record):
68 for field, field_schema in schema['properties'].items():
69 if field_schema.get('format') == 'time':
70 # `time` fields come back from Google like `X days, H:M:S`
71 old_time = record[field]
72 new_time = old_time.split(',')[1].strip()
73 record[field] = new_time
74 return record
75
67# Transform/validate batch of records w/ schema and sent to target 76# Transform/validate batch of records w/ schema and sent to target
68def process_records(catalog, 77def process_records(catalog,
69 stream_name, 78 stream_name,
@@ -78,8 +87,9 @@ def process_records(catalog,
78 # Transform record for Singer.io 87 # Transform record for Singer.io
79 with Transformer() as transformer: 88 with Transformer() as transformer:
80 try: 89 try:
90 edited_record = drop_date_on_time(schema, record)
81 transformed_record = transformer.transform( 91 transformed_record = transformer.transform(
82 record, 92 edited_record,
83 schema, 93 schema,
84 stream_metadata) 94 stream_metadata)
85 except Exception as err: 95 except Exception as err: