Skip to content

Commit

Permalink
[AIRFLOW-3419] Fix S3Hook.select_key on Python3 (#4970)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashb authored Mar 27, 2019
1 parent 74155f5 commit 8eaaec6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion airflow/hooks/S3_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def select_key(self, key, bucket_name=None,
InputSerialization=input_serialization,
OutputSerialization=output_serialization)

return ''.join(event['Records']['Payload']
return ''.join(event['Records']['Payload'].decode('utf-8')
for event in response['Payload']
if 'Records' in event)

Expand Down
2 changes: 1 addition & 1 deletion tests/hooks/test_s3_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def test_read_key(self):
@mock.patch('airflow.contrib.hooks.aws_hook.AwsHook.get_client_type')
def test_select_key(self, mock_get_client_type):
mock_get_client_type.return_value.select_object_content.return_value = \
{'Payload': [{'Records': {'Payload': u'Contént'}}]}
{'Payload': [{'Records': {'Payload': b'Cont\xC3\xA9nt'}}]}
hook = S3Hook(aws_conn_id=None)
self.assertEqual(hook.select_key('my_key', 'mybucket'), u'Contént')

Expand Down

0 comments on commit 8eaaec6

Please sign in to comment.