robertwb commented on code in PR #32342:
URL: https://github.com/apache/beam/pull/32342#discussion_r1733607147
##########
sdks/python/apache_beam/yaml/yaml_io.py:
##########
@@ -259,7 +259,7 @@ def _create_formatter(
field_names = [field.name for field in beam_schema.fields]
if len(field_names) != 1:
raise ValueError(f'Expecting exactly one field, found {field_names}')
- return lambda row: getattr(row, field_names[0])
+ return lambda row: getattr(row, field_names[0]).encode('utf-8')
Review Comment:
We can check the input type by querying `beam_schema.fields` just like we do
to ensure there's exactly one field and we know its name (though we should
ensure we properly handle the `Any` (aka "I don't know") type.
I can see that it could be convenient in some cases to turn things like
integers into decimal stringified bytes, but that's not always desirable and
feels a bit untypesafe. I'd prefer to err on the side of caution and reject
non-string-or-bytes (it'd be backwards compatible to allow that in the future
if we need, but not the other way around).
--
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]