pabloem commented on a change in pull request #15424:
URL: https://github.com/apache/beam/pull/15424#discussion_r710320880
##########
File path: sdks/python/apache_beam/io/gcp/bigquery_read_it_test.py
##########
@@ -68,16 +68,30 @@ def wrapped(self):
return inner
-def datetime_to_utc(element):
- for k, v in element.items():
- if isinstance(v, (datetime.time, datetime.date)):
- element[k] = str(v)
- if isinstance(v, datetime.datetime) and v.tzinfo:
- # For datetime objects, we'll
- offset = v.utcoffset()
- utc_dt = (v - offset).strftime('%Y-%m-%d %H:%M:%S.%f UTC')
- element[k] = utc_dt
- return element
+class CheckPythonTypes(beam.DoFn):
+ def process(self, element):
+ for key, value in element.items():
+ if key == 'bool':
+ isinstance(value, bool)
+ elif key == 'bytes':
+ isinstance(value, bytes)
+ elif key == 'int':
+ isinstance(value, int)
+ elif key == 'float':
+ isinstance(value, float)
+ elif key == 'numeric':
+ isinstance(value, Decimal)
+ elif key == 'rec':
+ isinstance(value, dict)
+ elif key == 'date':
+ isinstance(value, datetime.date)
+ elif key == 'time':
+ isinstance(value, datetime.time)
+ elif key == 'timestamp':
+ isinstance(value, datetime.datetime)
+ else:
+ # Includes STRING and GEOGRAPHY types.
+ isinstance(value, str)
Review comment:
I suppose you want to add assertions in these checks?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]